aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/timestamp.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-06-30 07:14:09 -0400
committerJosé Valim <jose.valim@gmail.com>2010-07-08 22:43:18 +0200
commit01629d180468049d17a8be6900e27a4f0d2b18c4 (patch)
treed3292821180ce99b8d9f53c35ab7b32b67364c95 /activerecord/lib/active_record/timestamp.rb
parent690352dce492938ab54a4b7e2befbd0a6931de3c (diff)
downloadrails-01629d180468049d17a8be6900e27a4f0d2b18c4.tar.gz
rails-01629d180468049d17a8be6900e27a4f0d2b18c4.tar.bz2
rails-01629d180468049d17a8be6900e27a4f0d2b18c4.zip
This patch changes update_attribute implementatino so:
- it will only save the attribute it has been asked to save and not all dirty attributes - it does not invoke callbacks - it does change updated_at/on Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/timestamp.rb')
-rw-r--r--activerecord/lib/active_record/timestamp.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb
index da8324ddcc..e6d52744df 100644
--- a/activerecord/lib/active_record/timestamp.rb
+++ b/activerecord/lib/active_record/timestamp.rb
@@ -58,14 +58,22 @@ module ActiveRecord
end
def update(*args) #:nodoc:
- if record_timestamps && (!partial_updates? || changed?)
+ record_update_timestamps
+ super
+ end
+
+ def record_update_timestamps
+ if should_record_update_timestamps
current_time = current_time_from_proper_timezone
timestamp_attributes_for_update_in_model.each { |column| write_attribute(column.to_s, current_time) }
end
+ end
- super
+ def should_record_update_timestamps
+ record_timestamps && (!partial_updates? || changed?)
end
+
def timestamp_attributes_for_update #:nodoc:
[:updated_at, :updated_on]
end