aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-02 15:40:11 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-02 15:40:11 -0700
commit7963c5d841c2c518d1087558f51a904060a9d305 (patch)
treebd5ed6d7da56a3153e9cd1e5f1e4364d999d1973 /activerecord/lib/active_record/associations.rb
parent0af978d33489c3ab54084c26d1354837b16f0cf5 (diff)
downloadrails-7963c5d841c2c518d1087558f51a904060a9d305.tar.gz
rails-7963c5d841c2c518d1087558f51a904060a9d305.tar.bz2
rails-7963c5d841c2c518d1087558f51a904060a9d305.zip
have the builder create the middle reflection
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rw-r--r--activerecord/lib/active_record/associations.rb13
1 files changed, 2 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 6ceefdf879..69ed7cc078 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1574,18 +1574,9 @@ module ActiveRecord
join_model = builder.through_model
- middle_name = [self.name.downcase.pluralize, name].join('_').gsub(/::/, '_').to_sym
-
- middle_options = builder.middle_options join_model
-
- hm_builder = Builder::HasMany.create_builder(self,
- middle_name,
- nil,
- middle_options)
- middle_reflection = hm_builder.build self
+ middle_reflection = builder.middle_reflection join_model
Builder::HasMany.define_callbacks self, middle_reflection
-
Reflection.add_reflection self, middle_reflection.name, middle_reflection
include Module.new {
@@ -1599,7 +1590,7 @@ module ActiveRecord
}
hm_options = {}
- hm_options[:through] = middle_name
+ hm_options[:through] = middle_reflection.name
hm_options[:source] = join_model.right_association_name
[:before_add, :after_add, :before_remove, :after_remove].each do |k|