提交 5178e641 编写于 作者: F Franck Verrot 提交者: Santiago Pastorino

Added timestamp_attributes_for_create_in_model

Signed-off-by: NSantiago Pastorino <santiago@wyeworks.com>
上级 598b32c5
......@@ -66,6 +66,10 @@ def should_record_timestamps?
self.record_timestamps && (!partial_updates? || changed? || (attributes.keys & self.class.serialized_attributes.keys).present?)
end
def timestamp_attributes_for_create_in_model
timestamp_attributes_for_create.select { |c| self.class.column_names.include?(c.to_s) }
end
def timestamp_attributes_for_update_in_model
timestamp_attributes_for_update.select { |c| self.class.column_names.include?(c.to_s) }
end
......
......@@ -155,4 +155,9 @@ def test_all_timestamp_attributes
toy = Toy.first
assert_equal toy.send(:all_timestamp_attributes), [:created_at, :created_on, :updated_at, :updated_on]
end
def test_timestamp_attributes_for_create_in_model
toy = Toy.first
assert_equal toy.send(:timestamp_attributes_for_create_in_model), [:created_at]
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册