aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index 9ec63e3fca..177d7905c7 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -53,7 +53,11 @@ module ActiveRecord
when @reflection.association_foreign_key.to_s
attrs[relation[column.name]] = record.id
else
- if record.has_attribute?(column.name)
+ if record.send(:all_timestamp_attributes).include?(column.name.to_sym)
+ if record.record_timestamps
+ attrs[relation[column.name]] = record.send(:current_time_from_proper_timezone)
+ end
+ elsif record.has_attribute?(column.name)
value = @owner.send(:quote_value, record[column.name], column)
attrs[relation[column.name]] = value unless value.nil?
end