2013-11-21 40 views
2

我有一个rails 4应用程序,我想在其中使用Best in Place或Rest Place或任何Gem来提供就地编辑。什么可能会阻止我的rails 4应用程序就地编辑?

我试过这两个。对于这两者,我将用户的“名称”属性设置为可编辑。

当我访问用户的显示页面时,单击该名称并显示输入字段。但提交时,它不会更新记录。

日志:

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 

它可以是正在发送的消息是PUT而不是补丁?在用户控制器

我的更新动作:

def update 
    if @user.update_attributes(user_params) 
     flash[:success] = "Perfil actualizado" 
     sign_in @user 
     redirect_to @user 
    else 
     render 'edit' 
    end 
end 

任何帮助将非常感激。

谢谢!

+0

你的路线文件是什么? – ksu

回答

1

如果更改

if @user.update_attributes(user_params) 

以下几点:

if @user.update_attributes!(user_params) 

您将有错误的更详细消息。

如果这不起作用,请尝试Rails.logger.debug(user_params)在日志中查看您的params散列。

摘要:

def update 
    if @user.update_attributes!(user_params) 
     flash[:success] = "Perfil actualizado" 
     sign_in @user 
     redirect_to @user 
    else 
     render 'edit' 
    end 
end 

调试据此!

+0

感谢jquadrin,更详细的错误消息,我刚刚意识到user_params还发送了一个'密码'参数与空值不通过验证。感谢致敬。 –

相关问题