diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 7c032d1a9d361d3d37b4b6864b9dd960bb8ffe10..91c6a683b1d6dfc1fa1818ae1d1010f1b4c4afd1 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,16 @@ *SVN* +* Added Base#update_attributes that'll accept a hash of attributes and save the record (returning true if it passed validation, false otherwise). + + Before: + person.attributes = @params["person"] + person.save + + 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 2bcea9dd5d8d53281477f20f3155a649caec204f..81f9f84d210224e0e751a9f68a2edd4f0233697b 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -789,7 +789,13 @@ def clone # Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records. def update_attribute(name, value) self[name] = value - save + return save + end + + # Updates all the attributes in from the passed hash and saves the record. + def update_attributes(attributes) + attributes = attributes + return save end # Returns the value of attribute identified by attr_name after it has been type cast (for example,