Added timestamp_attributes_for_create_in_model

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Franck Verrot 2011-01-25 23:27:27 +01:00 committed by Santiago Pastorino
parent 598b32c581
commit 5178e64175
2 changed files with 9 additions and 0 deletions

@ -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