diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-03-27 08:22:32 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-03-27 08:22:32 +0000 |
commit | 68ade93cde3fcb3ac9fdfe0541d33d22c2c748d7 (patch) | |
tree | 744c4945f86603985402e40a4d519f6a4bd15a36 /activerecord/lib | |
parent | 62937b8fb09f351e94f84d1f6e275e259784b8c0 (diff) | |
download | rails-68ade93cde3fcb3ac9fdfe0541d33d22c2c748d7.tar.gz rails-68ade93cde3fcb3ac9fdfe0541d33d22c2c748d7.tar.bz2 rails-68ade93cde3fcb3ac9fdfe0541d33d22c2c748d7.zip |
Revert "Changed behavior of touch and added touch! Originally implemented by Obie Fernandez, updated touch! to act as a thin wrapper to touch. [#2520 state:resolved]"
This reverts commit 3a875e618487a06a56f6cf912cf5440f294921cc.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/timestamp.rb | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index cd13ea0d09..da075dabd3 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -18,8 +18,9 @@ module ActiveRecord self.record_timestamps = true end - # Updates only the record's updated_at/on attributes to the current time without checking validations. - # If an attribute name is passed, that attribute is used instead of the updated_at/on attributes. + # Saves the record with the updated_at/on attributes set to the current time. + # If the save fails because of validation errors, an ActiveRecord::RecordInvalid exception is raised. + # If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes. # # Examples: # @@ -29,24 +30,13 @@ module ActiveRecord current_time = current_time_from_proper_timezone if attribute - update_attribute(attribute, current_time) + write_attribute(attribute, current_time) else - update_attribute('updated_at', current_time) if respond_to?(:updated_at) - update_attribute('updated_on', current_time) if respond_to?(:updated_on) + write_attribute('updated_at', current_time) if respond_to?(:updated_at) + write_attribute('updated_on', current_time) if respond_to?(:updated_on) end - end - - # Saves the entire record with the updated_at/on attributes set to the current time. - # If the save fails because of validation errors, an ActiveRecord::RecordInvalid exception is raised. - # If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes. - # - # Examples: - # - # product.touch! # updates updated_at - # product.touch!(:designed_at) # updates the designed_at attribute - def touch!(attribute = nil) - raise ActiveRecord::RecordInvalid.new(self) unless valid? - touch(attribute) + + save! end |