aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-18 11:17:22 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-18 11:17:22 +0000
commitd678997688f2e455088cd09b0edd25c7f96c3787 (patch)
treea5061b7754f28cd475b6496f6a71f6c4afd1b9c3 /activerecord/lib/active_record/base.rb
parent3bef4c246a3d2e1a53b874c09b0a4b22cfbae067 (diff)
downloadrails-d678997688f2e455088cd09b0edd25c7f96c3787.tar.gz
rails-d678997688f2e455088cd09b0edd25c7f96c3787.tar.bz2
rails-d678997688f2e455088cd09b0edd25c7f96c3787.zip
Base#update_attribute isnt subject to validation
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@210 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
1 files changed, 5 insertions, 2 deletions
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