Are there any other ways to set attributes for models in Rails other than using attribute=?
For example, is there something like set_attribute(name, value)?
user = User.new
user.set_attribute(:name, 'Jack')
user.set_attribute(:surname, 'The Ripper')
user.save
# instead of
user.name = 'Jack'
user.surname = 'The Ripper'
There is a write_attribute method. It should be what you’re looking for.
EDIT
You can use update_attributes if you want to update many attributes at once.