diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-02-14 01:07:48 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-02-14 01:40:31 +0000 |
commit | c9b685e681ea5851c2baaaec780fcc9c6a9e2775 (patch) | |
tree | 7ee7d4f12437244e952dcb60c64258cf23cd266f /activerecord/lib/active_record | |
parent | db03308451497dd6c7fa6e531b378f63f0781e7c (diff) | |
download | rails-c9b685e681ea5851c2baaaec780fcc9c6a9e2775.tar.gz rails-c9b685e681ea5851c2baaaec780fcc9c6a9e2775.tar.bz2 rails-c9b685e681ea5851c2baaaec780fcc9c6a9e2775.zip |
@target should always be an array
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index b8187b1c6a..8b5e600c96 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -354,12 +354,13 @@ module ActiveRecord def add_to_target(record) callback(:before_add, record) yield(record) if block_given? - @target ||= [] unless loaded? + if @reflection.options[:uniq] && index = @target.index(record) @target[index] = record else @target << record end + callback(:after_add, record) set_inverse_instance(record) record |