diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-22 00:19:59 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-23 15:19:17 -0800 |
commit | ff7bde62c857ec94f45a5be3bc76468deb8b0b3a (patch) | |
tree | 64bb289a46f3de6216748aae5b1d2fd2d253f8a6 /activerecord/lib/active_record/associations | |
parent | 030480ac1f4fbf8bf74a0d9298544426caf26894 (diff) | |
download | rails-ff7bde62c857ec94f45a5be3bc76468deb8b0b3a.tar.gz rails-ff7bde62c857ec94f45a5be3bc76468deb8b0b3a.tar.bz2 rails-ff7bde62c857ec94f45a5be3bc76468deb8b0b3a.zip |
When a has_many association is not :uniq, appending the same record multiple times should append it to the @target multiple times [#5964 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index c513e8ab08..7964f4fa2b 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -462,10 +462,10 @@ module ActiveRecord callback(:before_add, record) yield(record) if block_given? @target ||= [] unless loaded? - if index = @target.index(record) + if @reflection.options[:uniq] && index = @target.index(record) @target[index] = record else - @target << record + @target << record end callback(:after_add, record) set_inverse_instance(record, @owner) |