From d3089adb1a76d0d0446e914e972cf3ef49964333 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 2 Oct 2013 15:43:22 -0700 Subject: keep track of the left and right reflections and expose those --- .../associations/builder/has_and_belongs_to_many.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb index 2f79976594..8df7e7857f 100644 --- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb +++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb @@ -46,8 +46,8 @@ module ActiveRecord::Associations::Builder attr_accessor :class_resolver attr_accessor :name attr_accessor :table_name_resolver - attr_accessor :left_association_name - attr_accessor :right_association_name + attr_accessor :left_reflection + attr_accessor :right_reflection end def self.table_name @@ -59,14 +59,14 @@ module ActiveRecord::Associations::Builder end def self.add_left_association(name, options) - self.left_association_name = name belongs_to name, options + self.left_reflection = reflect_on_association(name) end def self.add_right_association(name, options) rhs_name = name.to_s.singularize.to_sym - self.right_association_name = rhs_name belongs_to rhs_name, options + self.right_reflection = reflect_on_association(rhs_name) end } @@ -96,7 +96,7 @@ module ActiveRecord::Associations::Builder def middle_options(join_model) middle_options = {} middle_options[:class] = join_model - middle_options[:source] = join_model.left_association_name + middle_options[:source] = join_model.left_reflection.name if options.key? :foreign_key middle_options[:foreign_key] = options[:foreign_key] end -- cgit v1.2.3