Permalink
Browse files

No need to check for :uniq

[#5170 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent da84527 commit a44652baed1d26a4f63380c406e05f7a2ddd4a12 Neeraj Singh committed with josevalim Jul 22, 2010
Showing with 3 additions and 6 deletions.
  1. +3 −6 activerecord/lib/active_record/associations/association_collection.rb
@@ -478,13 +478,10 @@ def add_record_to_target_with_callbacks(record)
callback(:before_add, record)
yield(record) if block_given?
@target ||= [] unless loaded?
- index = @target.index(record)
- unless @reflection.options[:uniq] && index
- if index
- @target[index] = record
- else
+ if index = @target.index(record)
+ @target[index] = record
+ else
@target << record
- end
end
callback(:after_add, record)
set_inverse_instance(record, @owner)

0 comments on commit a44652b

Please sign in to comment.