开发者

Rails 3 - Controller Def Update, is not updating the record & Not erroring?

Here's is my permissions controller for DEF UPDATE:

def update

  @permission = Permission.where(:user_id=> params[:permission][:user_id] ).where(:project_id=> params[:permission][:project_id]).first

  respond_to do |format|
    if @permission.update_attributes( params[:role_id] )
        format.js  { render :layout => false }
    else
        format.js  { render :layout => false }
    end
  end

Form Post Header utf8:✓ _method:put authe开发者_高级运维nticity_token:17rvYJmq7167 ktDBXZgDnopH3QY/Tb5a3K0jtcTjrU= permission%5Brole_id%5D:3 permission%5Buser_id%5D:11 permission%5Bproject_id%5D:3

No errors here, but the role_id is not being updated? Ideas? Thanks


You're passing params[:role_id] as the parameter to update_attributes, but this isn't set according to the post data you included.

I think what you probably mean is this:

if @permission.update_attribute(:role_id, params[:permission][:role_id])
    ...
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜