Change multiple object attributes in a single line

You want to use assign_attributes or update (which is an alias for the deprecated update_attributes):

@object.assign_attributes(:attr3 => "asdfasdf", :attr4 => "asdfasdf")

@object.update(attr3: "asdfasdf", attr4: "asdfasdf")

If you choose to update instead, the object will be saved immediately (pending any validations, of course).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)