heroku - Ruby on Rails: Update Attribute -
google failing me right now. need update 1 attribute, setting user admin, heroku rails console.
i can't find single simple answer. i've been trying is:
record.update_attribute(:roles_mask, "1")
where record correct record.
'undefined method 'update attribute''
i can't type record.roles_mask = 1
?
edit.
i used record, , shouldn't have done in example. i've done this:
ian = user.where(:id => '5') ian.update_attribute(:roles_mask, '1') error: undefined method 'update_attributes'
the problem using .where
function creates relation, rather finding record itself. this:
ian = user.find(5) ian.update_attribute(:roles_mask, '1')
or if want use .where
this:
ian = user.where(:id => 5) ian.first.update_attribute(:roles_mask, '1')
edit
see this answer details why happening.
Comments
Post a Comment