From 83e2f6ae1e1d4c6863b7c0514d55d7641fbd7513 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 18 Jul 2005 11:06:41 +0000 Subject: Allow unspecified join-table columns to use to their default values when adding to a habtm collection git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1860 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../associations/has_and_belongs_to_many_association.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations') 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 9183445d74..107f3ef12c 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 @@ -122,8 +122,10 @@ module ActiveRecord when @association_foreign_key attributes[column.name] = record.quoted_id else - value = @owner.send(:quote, record[column.name], column) - attributes[column.name] = value unless value.nil? + if record.attributes.has_key?(column.name) + value = @owner.send(:quote, record[column.name], column) + attributes[column.name] = value unless value.nil? + end end attributes end -- cgit v1.2.3