Ramazan Zor
Ramazan Zor

Reputation: 209

Rails update join table attributes

I have User, Attachment and Form models

 form = @user.forms.where(attachment_id: attachment.id)
 form.update_attributes(status: "full")

when I try to update a join table attribute, it says

undefined method `update_attributes

in my models there are only necessary has_many or belongs to attributes. I don't understand why update_attributes does not work

Upvotes: 0

Views: 1393

Answers (1)

J Plato
J Plato

Reputation: 898

where() returns a relation, not an individual ActiveRecord object. If you want to update an individual form, use find_by()

form = @user.forms.find_by(attachment_id: attachment.id)

Upvotes: 2

Related Questions