diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 15:40:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 15:40:11 -0700 |
commit | 7963c5d841c2c518d1087558f51a904060a9d305 (patch) | |
tree | bd5ed6d7da56a3153e9cd1e5f1e4364d999d1973 /activerecord/lib/active_record/associations.rb | |
parent | 0af978d33489c3ab54084c26d1354837b16f0cf5 (diff) | |
download | rails-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.rb | 13 |
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| |