Reputation: 451
I have a rails 4 app in which i want to use Best in Place or Rest in Place or any gem to provide in-place editing.
I've tried with those two. With both, I set the "name" attribute of a User to be editable in place.
When I visit the show page of a user, I click the name and the input field appears. But when submitted, it won't update the record.
Logs:
Processing by UsersController#update as JSON
Parameters: {"user"=>{"name"=>"lkj"}, "authenticity_token"=>"TOz1cbnLc5KrX5JLZl0hiOsf7ZvwXhp6lD2qUIfH+og=", "id"=>"7"}
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '62f0af062cc8544a31bfe5a02ef00bf34d449959' LIMIT 1
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", "7"]]
(0.1ms) begin transaction
User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE (LOWER("users"."email") = LOWER('[email protected]') AND "users"."id" != 7) LIMIT 1
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 41ms
Can it be that the message being sent is a PUT and not PATCH?
My Update action in Users controller:
def update
if @user.update_attributes(user_params)
flash[:success] = "Perfil actualizado"
sign_in @user
redirect_to @user
else
render 'edit'
end
end
Any help will be much appreciated.
Thanks!
Upvotes: 2
Views: 894
Reputation: 246
If you change
if @user.update_attributes(user_params)
to the following:
if @user.update_attributes!(user_params)
You will have a more detailed message of the error.
if this does not work, try Rails.logger.debug(user_params)
to view your params hash in the logs.
summary:
def update
if @user.update_attributes!(user_params)
flash[:success] = "Perfil actualizado"
sign_in @user
redirect_to @user
else
render 'edit'
end
end
Debug accordingly!
Upvotes: 1