Permalink
Browse files

Added timestamp_attributes_for_create_in_model

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
1 parent 598b32c commit 5178e641750d4e3f8419c8e6cf3ab7e7cb48a880 @franckverrot franckverrot committed with spastorino Jan 25, 2011
Showing with 9 additions and 0 deletions.
  1. +4 −0 activerecord/lib/active_record/timestamp.rb
  2. +5 −0 activerecord/test/cases/timestamp_test.rb
View
4 activerecord/lib/active_record/timestamp.rb
@@ -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
View
5 activerecord/test/cases/timestamp_test.rb
@@ -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

0 comments on commit 5178e64

Please sign in to comment.