Problem updating data

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” %>

Edit User
<% 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 class="formlabel"><label

for=“user_address”>Address:


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

for=“user_phone”>Phone:

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

for=“user_email”>Email:

<%= form.text_field :email, :size => 40
,:value => @olduserprofile.email %>
  <div class="formlabel">&nbsp;</div>
  <div class="forminput"><td colspan="2"><%= submit_tag "Edit

profile", :class => “submit” %>

 
<% end %>

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs