update_attributes 未保存到数据库

2024-04-24

提交表单后,正确的自定义参数显示在我的调试函数中,但当我进入控制台时显示默认参数。

控制器

def update
    current_user.update_attributes(params[:user])
    flash[:success] = "Your settings have been saved!"
    render new_status_update_path
end                                         

Model

attr_accessible :deficit_pct,
              :target_bf_pct,
              :activity_factor

Notes:

  • 我能在 SO 上找到的最接近的问题是更改通过关联存在的对象的属性的问题。

  • 我尝试使用 Object.update 方法,尽管我收到一条错误消息:

    私有方法“update”调用#

有任何想法吗?

Thanks!


尝试代码:-

def update
    if current_user.update_attributes(params[:user])
        flash[:success] = "Your settings have been saved!"
        render new_status_update_path
    else
        p 111111111111
        p  current_user.errors.inspect
    end
end

检查日志中是否有任何错误。该活动记录是否存在

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

update_attributes 未保存到数据库 的相关文章

随机推荐