diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-08-29 17:39:09 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-08-29 17:39:09 +0100 |
commit | c59c9bb8bc275a2be8695d4d431a0512d29353f1 (patch) | |
tree | 0e42ec1ca8891f59c5879163758fa068c6a72aca /activerecord | |
parent | 735d985b0162976e7e900cf36d4cbb0d657fb5e9 (diff) | |
download | rails-c59c9bb8bc275a2be8695d4d431a0512d29353f1.tar.gz rails-c59c9bb8bc275a2be8695d4d431a0512d29353f1.tar.bz2 rails-c59c9bb8bc275a2be8695d4d431a0512d29353f1.zip |
Move clear_timestamp_attributes into Timestamp module
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/timestamp.rb | 14 |
2 files changed, 14 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 03aea81d2c..374791deb1 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1849,7 +1849,7 @@ MSG ensure_proper_type populate_with_current_scope_attributes - clear_timestamp_attributes + super end # Returns +true+ if the record is read only. Records loaded through joins with piggy-back @@ -2113,14 +2113,6 @@ MSG send("#{att}=", value) if respond_to?("#{att}=") end end - - # Clear attributes and changed_attributes - def clear_timestamp_attributes - all_timestamp_attributes_in_model.each do |attribute_name| - self[attribute_name] = nil - changed_attributes.delete(attribute_name) - end - end end Base.class_eval do diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 1511c71ffc..6b8c52861e 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -37,6 +37,11 @@ module ActiveRecord self.record_timestamps = true end + def initialize_dup(other) + clear_timestamp_attributes + super + end + private def create #:nodoc: @@ -95,6 +100,13 @@ module ActiveRecord def current_time_from_proper_timezone #:nodoc: self.class.default_timezone == :utc ? Time.now.utc : Time.now end + + # Clear attributes and changed_attributes + def clear_timestamp_attributes + all_timestamp_attributes_in_model.each do |attribute_name| + self[attribute_name] = nil + changed_attributes.delete(attribute_name) + end + end end end - |