aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/has_many_through_association.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/has_many_through_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index c4d3ef8fef..664c284d45 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -22,7 +22,7 @@ module ActiveRecord
end
end
- def <<(*records)
+ def concat(*records)
unless @owner.new_record?
records.flatten.each do |record|
raise_on_type_mismatch(record)
@@ -33,19 +33,17 @@ module ActiveRecord
super
end
- protected
-
- def insert_record(record, validate = true)
- return if record.new_record? && !record.save(:validate => validate)
- through_record(record).save!
- update_counter(1)
- record
- end
+ def insert_record(record, validate = true)
+ return if record.new_record? && !record.save(:validate => validate)
+ through_record(record).save!
+ update_counter(1)
+ record
+ end
private
def through_record(record)
- through_association = @owner.send(:association_proxy, @reflection.through_reflection.name)
+ through_association = @owner.association(@reflection.through_reflection.name)
attributes = construct_join_attributes(record)
through_record = Array.wrap(through_association.target).find { |candidate|
@@ -95,7 +93,7 @@ module ActiveRecord
end
def delete_records(records, method)
- through = @owner.send(:association_proxy, @reflection.through_reflection.name)
+ through = @owner.association(@reflection.through_reflection.name)
scope = through.scoped.where(construct_join_attributes(*records))
case method