From 573fd39e22b3d278457fa764c107095808b361fe Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 30 Dec 2010 18:41:53 +0000 Subject: Make sure Model#touch doesn't try to update non existing columns --- activerecord/lib/active_record/timestamp.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/timestamp.rb') diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 2ecbd906bd..5617adea1f 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -67,7 +67,7 @@ module ActiveRecord end def timestamp_attributes_for_update_in_model - timestamp_attributes_for_update.select { |c| respond_to?(c) } + timestamp_attributes_for_update.select { |c| self.class.column_names.include?(c.to_s) } end def timestamp_attributes_for_update #:nodoc: -- cgit v1.2.3 From 5178e641750d4e3f8419c8e6cf3ab7e7cb48a880 Mon Sep 17 00:00:00 2001 From: Franck Verrot Date: Tue, 25 Jan 2011 23:27:27 +0100 Subject: Added timestamp_attributes_for_create_in_model Signed-off-by: Santiago Pastorino --- activerecord/lib/active_record/timestamp.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record/timestamp.rb') diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 5617adea1f..38cc2c9694 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -66,6 +66,10 @@ module ActiveRecord 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 -- cgit v1.2.3 From a5b03e9c7af8f539764a66f9bd51b7ebbcb9f57d Mon Sep 17 00:00:00 2001 From: Franck Verrot Date: Tue, 25 Jan 2011 23:33:55 +0100 Subject: Implement and test private method all_timestamp_attributes_in_model Signed-off-by: Santiago Pastorino --- activerecord/lib/active_record/timestamp.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record/timestamp.rb') diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 38cc2c9694..65d9d1fb19 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -74,6 +74,10 @@ module ActiveRecord timestamp_attributes_for_update.select { |c| self.class.column_names.include?(c.to_s) } end + def all_timestamp_attributes_in_model + timestamp_attributes_for_create_in_model + timestamp_attributes_for_update_in_model + end + def timestamp_attributes_for_update #:nodoc: [:updated_at, :updated_on] end -- cgit v1.2.3 From c56e314866dff5d72c2a90e5e785c9a12d73d22b Mon Sep 17 00:00:00 2001 From: Brian Morearty Date: Sat, 5 Feb 2011 09:07:00 -0800 Subject: Updates to ActiveRecord::Timestamp documentation. Change ActiveRecord::Base.xyz to config.active_record.xyz in docs. Remove from code samples. Update skip_time_zone_conversion_for_attributes code sample: put the call in the model class. Clarify that skip_time_zone_conversion_for_attributes skips converion when reading. --- activerecord/lib/active_record/timestamp.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record/timestamp.rb') diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb index 65d9d1fb19..1511c71ffc 100644 --- a/activerecord/lib/active_record/timestamp.rb +++ b/activerecord/lib/active_record/timestamp.rb @@ -9,24 +9,26 @@ module ActiveRecord # # Timestamping can be turned off by setting: # - # ActiveRecord::Base.record_timestamps = false + # config.active_record.record_timestamps = false # # Timestamps are in the local timezone by default but you can use UTC by setting: # - # ActiveRecord::Base.default_timezone = :utc + # config.active_record.default_timezone = :utc # # == Time Zone aware attributes # # By default, ActiveRecord::Base keeps all the datetime columns time zone aware by executing following code. # - # ActiveRecord::Base.time_zone_aware_attributes = true + # config.active_record.time_zone_aware_attributes = true # # This feature can easily be turned off by assigning value false . # - # If your attributes are time zone aware and you desire to skip time zone conversion for certain - # attributes then you can do following: + # If your attributes are time zone aware and you desire to skip time zone conversion to the current Time.zone + # when reading certain attributes then you can do following: # - # Topic.skip_time_zone_conversion_for_attributes = [:written_on] + # class Topic < ActiveRecord::Base + # self.skip_time_zone_conversion_for_attributes = [:written_on] + # end module Timestamp extend ActiveSupport::Concern -- cgit v1.2.3