diff options
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 91c6a683b1..db2b44ac02 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -9,8 +9,6 @@ Now: person.update_attributes(@params["person"]) -* Added a return value for Base#update_attribute, so that you get to know whether the save was successful or if it failed validation. - * Added Base.destroy and Base.delete to remove records without holding a reference to them first. diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c10644ca3e..b0de050185 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -787,12 +787,15 @@ module ActiveRecord #:nodoc: end # Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records. + # Note: This method is overwritten by the Validation module that'll make sure that updates made with this method + # doesn't get subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid. def update_attribute(name, value) self[name] = value - return save + return true end - # Updates all the attributes in from the passed hash and saves the record. + # Updates all the attributes in from the passed hash and saves the record. If the object is invalid, the saving will + # fail and false will be returned. def update_attributes(attributes) self.attributes = attributes return save |