From 17bf66295d52055480c024346e3a551521962cae Mon Sep 17 00:00:00 2001 From: Drew Date: Sun, 19 Apr 2009 07:51:19 -0600 Subject: [PATCH] Changed ActiveRecord#touch to avoid calling validations on save --- activerecord/lib/active_record/timestamp.rb | 5 +++-- activerecord/test/cases/timestamp_test.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index d9e1ef3..c37f643 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -17,7 +17,8 @@ module ActiveRecord end # 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. + # The attribute is updated and saved whether or not the model is valid + # # If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes. # # Examples: @@ -34,7 +35,7 @@ module ActiveRecord write_attribute('updated_on', current_time) if respond_to?(:updated_on) end - save! + save(false) end diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb index 24b237a..5b00874 100644 --- a/activerecord/test/cases/timestamp_test.rb +++ b/activerecord/test/cases/timestamp_test.rb @@ -25,7 +25,7 @@ class TimestampTest < ActiveRecord::TestCase end def test_touching_a_record_updates_its_timestamp - @developer.touch + assert @developer.touch assert @previously_updated_at != @developer.updated_at end -- 1.6.2.1217.gd7bc3