diff options
author | Jamis Buck <jamis@37signals.com> | 2005-07-18 11:06:41 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-07-18 11:06:41 +0000 |
commit | 83e2f6ae1e1d4c6863b7c0514d55d7641fbd7513 (patch) | |
tree | a5fd59656b43becc1735827fb690835867a8fd91 /activerecord/lib/active_record/associations | |
parent | 2e175d35cd4fc4438f6d263c8fe205939cd4b95f (diff) | |
download | rails-83e2f6ae1e1d4c6863b7c0514d55d7641fbd7513.tar.gz rails-83e2f6ae1e1d4c6863b7c0514d55d7641fbd7513.tar.bz2 rails-83e2f6ae1e1d4c6863b7c0514d55d7641fbd7513.zip |
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
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 6 |
1 files changed, 4 insertions, 2 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 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 |