Rails 更新加入 table 属性
Rails update join table attributes
我有用户、附件和表单模型
form = @user.forms.where(attachment_id: attachment.id)
form.update_attributes(status: "full")
当我尝试更新联接 table 属性时,它显示
undefined method `update_attributes
在我的模型中只有必要的 has_many 或属于属性。我不明白为什么 update_attributes 不起作用
where() returns 一个关系,而不是一个单独的 ActiveRecord 对象。如果要更新单个表单,请使用 find_by()
form = @user.forms.find_by(attachment_id: attachment.id)
我有用户、附件和表单模型
form = @user.forms.where(attachment_id: attachment.id)
form.update_attributes(status: "full")
当我尝试更新联接 table 属性时,它显示
undefined method `update_attributes
在我的模型中只有必要的 has_many 或属于属性。我不明白为什么 update_attributes 不起作用
where() returns 一个关系,而不是一个单独的 ActiveRecord 对象。如果要更新单个表单,请使用 find_by()
form = @user.forms.find_by(attachment_id: attachment.id)