Skip to content
Browse files

Added Base#update_attributes that'll accept a hash of attributes and …

…save the record (returning true if it passed validation, false otherwise). Added a return value for Base#update_attribute, so that you get to know whether the save was successful or if it failed validation.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@207 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 648b8fd commit 604a09462eb6ad9eec0bd8ba3f100f6c402945e3 @dhh dhh committed Dec 17, 2004
Showing with 18 additions and 1 deletion.
  1. +11 −0 activerecord/CHANGELOG
  2. +7 −1 activerecord/lib/active_record/base.rb
View
11 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.
View
8 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 <tt>attr_name</tt> after it has been type cast (for example,

0 comments on commit 604a094

Please sign in to comment.
Something went wrong with that request. Please try again.