提交 c59c9bb8 编写于 作者: J Jon Leighton

Move clear_timestamp_attributes into Timestamp module

上级 735d985b
......@@ -1849,7 +1849,7 @@ def initialize_dup(other)
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 @@ def populate_with_current_scope_attributes
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
......
......@@ -37,6 +37,11 @@ module Timestamp
self.record_timestamps = true
end
def initialize_dup(other)
clear_timestamp_attributes
super
end
private
def create #:nodoc:
......@@ -95,6 +100,13 @@ def all_timestamp_attributes #:nodoc:
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册