aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/timestamp.rb
diff options
context:
space:
mode:
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