public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Simplify ActiveRecord::Base#update_attribute
lifo (author)
Fri Jun 06 17:25:27 -0700 2008
commit  89ea7bee3609e513b21151eb4a7991b074fc0e8f
tree    aadd305fe0cb62053886f9608fea0b20b52e832f
parent  e79d47847a75d63a66a3ed2296271fd28d41f24c
...
2252
2253
2254
2255
2256
2257
 
 
 
2258
2259
2260
 
2261
2262
2263
...
2252
2253
2254
 
 
 
2255
2256
2257
2258
2259
 
2260
2261
2262
2263
0
@@ -2252,12 +2252,12 @@ module ActiveRecord #:nodoc:
0
         end
0
       end
0
 
0
- # Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records.
0
- # Note: This method is overwritten by the Validation module that'll make sure that updates made with this method
0
- # aren't subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid.
0
+ # Updates a single attribute and saves the record without going through the normal validation procedure.
0
+ # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method
0
+ # in Base is replaced with this when the validations module is mixed in, which it is by default.
0
       def update_attribute(name, value)
0
         send(name.to_s + '=', value)
0
- save
0
+ save(false)
0
       end
0
 
0
       # Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will
...
277
278
279
280
281
282
283
...
914
915
916
917
918
919
920
921
922
923
924
925
926
927
...
277
278
279
 
280
281
282
...
913
914
915
 
 
 
 
 
 
 
 
916
917
918
0
@@ -277,7 +277,6 @@ module ActiveRecord
0
       base.class_eval do
0
         alias_method_chain :save, :validation
0
         alias_method_chain :save!, :validation
0
- alias_method_chain :update_attribute, :validation_skipping
0
       end
0
 
0
       base.send :include, ActiveSupport::Callbacks
0
@@ -914,14 +913,6 @@ module ActiveRecord
0
       end
0
     end
0
 
0
- # Updates a single attribute and saves the record without going through the normal validation procedure.
0
- # This is especially useful for boolean flags on existing records. The regular +update_attribute+ method
0
- # in Base is replaced with this when the validations module is mixed in, which it is by default.
0
- def update_attribute_with_validation_skipping(name, value)
0
- send(name.to_s + '=', value)
0
- save(false)
0
- end
0
-
0
     # Runs +validate+ and +validate_on_create+ or +validate_on_update+ and returns true if no errors were added otherwise false.
0
     def valid?
0
       errors.clear

Comments

    No one has commented yet.