aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorFranck Verrot <franck@verrot.fr>2010-11-24 16:32:41 +0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-25 01:18:43 +0800
commitc17cb7326d6af7c4226e955abd3f89db95fabb33 (patch)
tree902444b67e4583ed155d25eee3aa3ed079077c25 /activerecord/lib
parent47f39d26a76430ad50dae79f212d118849b2af40 (diff)
downloadrails-c17cb7326d6af7c4226e955abd3f89db95fabb33.tar.gz
rails-c17cb7326d6af7c4226e955abd3f89db95fabb33.tar.bz2
rails-c17cb7326d6af7c4226e955abd3f89db95fabb33.zip
Dup should reset the timestamps as it is considered a new record
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/base.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index d2fa3bed35..49b30f4779 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1625,6 +1625,7 @@ MSG
ensure_proper_type
populate_with_current_scope_attributes
+ clear_timestamp_attributes
end
# Returns +true+ if the record is read only. Records loaded through joins with piggy-back
@@ -1831,6 +1832,16 @@ MSG
create_with.each { |att,value| self.respond_to?(:"#{att}=") && self.send("#{att}=", value) } if create_with
end
end
+
+ # Clear attributes and changged_attributes
+ def clear_timestamp_attributes
+ %w(created_at created_on updated_at updated_on).each do |attribute_name|
+ if self.has_attribute?(attribute_name)
+ self[attribute_name] = nil
+ self.changed_attributes.delete(attribute_name)
+ end
+ end
+ end
end
Base.class_eval do