diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 15:43:22 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-02 15:43:22 -0700 |
commit | d3089adb1a76d0d0446e914e972cf3ef49964333 (patch) | |
tree | 9c828354d419ff8cfac1a17f32f5d7d75ab97e73 /activerecord/lib/active_record | |
parent | 7963c5d841c2c518d1087558f51a904060a9d305 (diff) | |
download | rails-d3089adb1a76d0d0446e914e972cf3ef49964333.tar.gz rails-d3089adb1a76d0d0446e914e972cf3ef49964333.tar.bz2 rails-d3089adb1a76d0d0446e914e972cf3ef49964333.zip |
keep track of the left and right reflections and expose those
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 69ed7cc078..09ed85ef24 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1591,7 +1591,7 @@ module ActiveRecord hm_options = {} hm_options[:through] = middle_reflection.name - hm_options[:source] = join_model.right_association_name + hm_options[:source] = join_model.right_reflection.name [:before_add, :after_add, :before_remove, :after_remove].each do |k| if options.key? k 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 |