aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-06-07 01:25:27 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-06-07 01:25:27 +0100
commit89ea7bee3609e513b21151eb4a7991b074fc0e8f (patch)
treeaadd305fe0cb62053886f9608fea0b20b52e832f /activerecord
parente79d47847a75d63a66a3ed2296271fd28d41f24c (diff)
downloadrails-89ea7bee3609e513b21151eb4a7991b074fc0e8f.tar.gz
rails-89ea7bee3609e513b21151eb4a7991b074fc0e8f.tar.bz2
rails-89ea7bee3609e513b21151eb4a7991b074fc0e8f.zip
Simplify ActiveRecord::Base#update_attribute
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb8
-rwxr-xr-xactiverecord/lib/active_record/validations.rb9
2 files changed, 4 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 110902b590..450ea5cb33 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2252,12 +2252,12 @@ module ActiveRecord #:nodoc:
end
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
- # aren't subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid.
+ # Updates a single attribute and saves the record without going through the normal validation procedure.
+ # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method
+ # in Base is replaced with this when the validations module is mixed in, which it is by default.
def update_attribute(name, value)
send(name.to_s + '=', value)
- save
+ save(false)
end
# Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index c97aafb126..c4e370d017 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -277,7 +277,6 @@ module ActiveRecord
base.class_eval do
alias_method_chain :save, :validation
alias_method_chain :save!, :validation
- alias_method_chain :update_attribute, :validation_skipping
end
base.send :include, ActiveSupport::Callbacks
@@ -914,14 +913,6 @@ module ActiveRecord
end
end
- # Updates a single attribute and saves the record without going through the normal validation procedure.
- # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method
- # in Base is replaced with this when the validations module is mixed in, which it is by default.
- def update_attribute_with_validation_skipping(name, value)
- send(name.to_s + '=', value)
- save(false)
- end
-
# Runs +validate+ and +validate_on_create+ or +validate_on_update+ and returns true if no errors were added otherwise false.
def valid?
errors.clear