if @user.save = @user.update_attributes(params[:user])
if @user.update_attributes(params[:user])
format.html {redirect_to(profile_path(@user), :notice => 'User
was successfully updated.')}
else
format.html { render action: "index" }
end
end
end
...........
In Route ...
match "/profile/:id" => "profile#index", :as => :profile
match "/profile/:id/edit" => "profile#edit", :as => :profile_edit
put '/profile/:id' => "profile#update" ## method = put for update
...............
In Model - update data be saved in user table.
.................
But I can't update data . In rails server screen , I see the edit
process.I can't see update process - like " Update user where
.........."
You need to look through the update method and ask yourself what each
line is doing. For example you seem to have two save calls and also
two update_attributes (which updates the object and saves it). That
is four saves all together. is that what you meant to do?
Then if it still does not work check in development.log to make sure
the action is being called with the correct parameters, then if still
not working debug into the update action to see what is going on.
Have a look at the Rails Guide on Debugging if you do not know how to
do that.
match "/profile/:id" => "profile#index", :as => :profile
match "/profile/:id/edit" => "profile#edit", :as => :profile_edit
put '/profile/:id' => "profile#update" ## method = put for update
Your update action looks a little confused - it's updating the record
4 times which seems overkill, but it looks like you're not ever
getting to the update action - if you were an exception would be
raised at the point where you do @user.save = ... (since there is no
save= method)
match (by default) accepts all http verbs, so when your put request
comes through it gets routed to profile#index. routes are considered
in the order they are defined, so although you do have a put specific
route, rails never even looks at it because it finds match '/
profile/:id' first.
You should either make the route to index action more specific (i.e.
say that it has to be a GET) or move the route to the update index
before it
routes are considered in the order they are defined, so although you do
have a put specific route, rails never even looks at it because it finds
match '/
profile/:id' first......