Forum: Ruby on Rails problem updating data

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ps_gem S. (Guest)
on 2009-04-20 00:59
It may be my stupid mistake; when I try to update users profile data it
doesn't update or give any error. Any help would be greatly appreciated.
Thanks
-----------------------------------------------------------
my users_controller.rb file:
------------------------------------------------------------
 def edit_userprofile
    @olduserprofile= User.find(session[:user_id])
  end

  def save_userprofile
    @newprofile = User.new(params[:newuserprofile])
    @upuser=User.find(params[:id])
    @upuser.name = @newprofile.name
    @upuser.phone = @newprofile.phone
    @upuser.address = @newprofile.address
    @upuser.email = @newprofile.email
    @upuser.save
    redirect_to :action => :edit_userprofile;
    flash.now[:notice] = "Your profile has been edited sucessfully"
  end

--------------------------------------------------------------------
edit_profile.rhtml:
--------------------------------------------------------------------

<%= "edit_userprofile" %>
  <div class="box">
  <div class="topic">Edit User</div>
  <div class="divpad">
    <% form_for :newuserprofile, :url => { :action =>
'save_userprofile', :id=>@olduserprofile} do|form|%>

      <div class="formlabel"><label for="user_name">Name:</label></div>
      <div class="forminput"><%= form.text_field :name, :size =>
40,:value => @olduserprofile.name %></div>

      <div class="formlabel"><label
for="user_address">Address:</label></div>
      <div class="forminput"><%= form.text_field :address, :size =>
40,:value => @olduserprofile.address %></div>

      <div class="formlabel"><label
for="user_phone">Phone:</label></div>
      <div class="forminput"><%= form.text_field :phone, :size => 40
,:value => @olduserprofile.phone %></div>

      <div class="formlabel"><label
for="user_email">Email:</label></div>
      <div class="forminput"><%= form.text_field :email, :size => 40
,:value => @olduserprofile.email %></div>

      <div class="formlabel">&nbsp;</div>
      <div class="forminput"><td colspan="2"><%= submit_tag "Edit
profile", :class => "submit" %></div>
      <div class="formlabel">&nbsp;</div>

    <% end %>
  </div>
  </div>
(Guest)
on 2009-04-21 16:48
(Received via mailing list)
The user data are invalid.
Replace "@upuser.save" with "@upuser.save!",
then it will raise an exception,
so you will know what's the problem.

Dmitry
This topic is locked and can not be replied to.