I have an update method in my users controller that I call from a HTTPService in Flex 4. The update method is as follows:
def updateName
@user = User.find_by_email(params[:email])
@user.name = params[:nameNew]
render :nothing => true
end
This is console output:
Processing UsersController#updateName
(for 127.0.0.1 at 2010-05-24 14:12:49)
[POST]Parameters: {“action”=>”updateName”,
“nameNew”=>”ben”,
“controller”=>”users”,
“email”=>”email@gmail.com”}User Load (0.6ms) SELECT * FROM
“users” WHERE (“users”.”email” =
’email@gmail.com’) LIMIT 1
Completed in 20ms (View: 1, DB: 1) |
200 OK
[http://localhost/users/updateName%5D
But when I check my database, the name field is never updated. What am I doing wrong? Thanks for reading.
You only modified user object in memory, i.e. you are not saving the change to database. You want something like:
Additionally you might want to put @user.save in an if-condition to check if model was saved correctly.