diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-19 16:13:06 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-19 16:13:06 +0100 |
commit | 915ea5ea826d48107e4c1953c7a32cf26727d10e (patch) | |
tree | 6d9c1284df9ac076d2b083737374f6b884f7197b /activerecord/lib/active_record/associations | |
parent | 0ceb34295501a797c9e549c581ecee17f837f01c (diff) | |
download | rails-915ea5ea826d48107e4c1953c7a32cf26727d10e.tar.gz rails-915ea5ea826d48107e4c1953c7a32cf26727d10e.tar.bz2 rails-915ea5ea826d48107e4c1953c7a32cf26727d10e.zip |
Support the :primary_key option on a through reflection in a nested through association
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association_scope.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/through_association_scope.rb b/activerecord/lib/active_record/associations/through_association_scope.rb index 1365851337..649bbd206a 100644 --- a/activerecord/lib/active_record/associations/through_association_scope.rb +++ b/activerecord/lib/active_record/associations/through_association_scope.rb @@ -76,14 +76,11 @@ module ActiveRecord right_table_and_alias = table_name_and_alias(right.quoted_table_name, table_aliases[right]) if left.source_reflection.nil? - # TODO: Perhaps need to pay attention to left.options[:primary_key] and - # left.options[:foreign_key] in places here - case left.macro when :belongs_to joins << inner_join_sql( right_table_and_alias, - table_aliases[left], left.klass.primary_key, + table_aliases[left], left.association_primary_key, table_aliases[right], left.primary_key_name, reflection_conditions(right_index) ) @@ -91,7 +88,7 @@ module ActiveRecord joins << inner_join_sql( right_table_and_alias, table_aliases[left], left.primary_key_name, - table_aliases[right], right.klass.primary_key, + table_aliases[right], right.association_primary_key, polymorphic_conditions(left, left), reflection_conditions(right_index) ) |