Added timestamp_attributes_for_create_in_model
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
parent
598b32c581
commit
5178e64175
@ -66,6 +66,10 @@ def should_record_timestamps?
|
|||||||
self.record_timestamps && (!partial_updates? || changed? || (attributes.keys & self.class.serialized_attributes.keys).present?)
|
self.record_timestamps && (!partial_updates? || changed? || (attributes.keys & self.class.serialized_attributes.keys).present?)
|
||||||
end
|
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
|
def timestamp_attributes_for_update_in_model
|
||||||
timestamp_attributes_for_update.select { |c| self.class.column_names.include?(c.to_s) }
|
timestamp_attributes_for_update.select { |c| self.class.column_names.include?(c.to_s) }
|
||||||
end
|
end
|
||||||
|
@ -155,4 +155,9 @@ def test_all_timestamp_attributes
|
|||||||
toy = Toy.first
|
toy = Toy.first
|
||||||
assert_equal toy.send(:all_timestamp_attributes), [:created_at, :created_on, :updated_at, :updated_on]
|
assert_equal toy.send(:all_timestamp_attributes), [:created_at, :created_on, :updated_at, :updated_on]
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user