1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

expanded comment for update_attribute method

This commit is contained in:
Neeraj Singh 2010-07-20 06:56:20 -04:00 committed by Xavier Noria
parent efdfcf1325
commit 5c137939a7

View file

@ -102,8 +102,15 @@ module ActiveRecord
became became
end end
# Updates a single attribute and saves the record without going through the normal validation procedure # Updates a single attribute and saves the record.
# or callbacks. This is especially useful for boolean flags on existing records. # This is especially useful for boolean flags on existing records. Also note that
#
# * validation is skipped
# * No callbacks are invoked
# * updated_at/updated_on column is updated if that column is available
# * does not work on associations
# * does not work on attr_accessor attributes. The attribute that is being updated must be column name.
#
def update_attribute(name, value) def update_attribute(name, value)
raise ActiveRecordError, "#{name.to_s} is marked as readonly" if self.class.readonly_attributes.include? name.to_s raise ActiveRecordError, "#{name.to_s} is marked as readonly" if self.class.readonly_attributes.include? name.to_s