глядя на источник AR, мы можем найти
# File activerecord/lib/active_record/persistence.rb, line 208
def update_attributes(attributes, options = {})
# The following transaction covers any possible database side-effects of the
# attributes assignment. For example, setting the IDs of a child collection.
with_transaction_returning_status do
self.assign_attributes(attributes, options)
save
end
end
, чтобы вы могли использовать assign_attributes(attributes, options)
для установки атрибутов без сохранения
Также, если вы хотите установить атрибут по имени без непосредственного вызова метода, вы можете использовать
user.send(:name=, 'Jack')
вместо user.set_attribute(:name, 'Jack')