diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-19 14:14:06 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-19 14:14:06 +0100 |
commit | 01838636c6136d9a649ace71db61bb7990f9bd82 (patch) | |
tree | 2f307e4dd6843588ab19f7d41615a04465560fff /activerecord/lib/active_record/associations.rb | |
parent | 596cc3b2329a9cc4a30c95c157ce36b2d08975df (diff) | |
download | rails-01838636c6136d9a649ace71db61bb7990f9bd82.tar.gz rails-01838636c6136d9a649ace71db61bb7990f9bd82.tar.bz2 rails-01838636c6136d9a649ace71db61bb7990f9bd82.zip |
Support for :primary_key option on the source reflection of a through association, where the source is a has_one or has_many
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 75e5eb8ee4..29f1c7b81d 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -2173,13 +2173,11 @@ module ActiveRecord if reflection.source_reflection.nil? case reflection.macro when :belongs_to - key = reflection.options[:primary_key] || - reflection.klass.primary_key + key = reflection.association_primary_key foreign_key = reflection.primary_key_name when :has_many, :has_one key = reflection.primary_key_name - foreign_key = reflection.options[:primary_key] || - reflection.active_record.primary_key + foreign_key = reflection.active_record_primary_key conditions << polymorphic_conditions(reflection, table) when :has_and_belongs_to_many @@ -2209,13 +2207,13 @@ module ActiveRecord else case reflection.source_reflection.macro when :belongs_to - key = reflection.klass.primary_key + key = reflection.source_reflection.association_primary_key foreign_key = reflection.source_reflection.primary_key_name conditions << source_type_conditions(reflection, foreign_table) when :has_many, :has_one key = reflection.source_reflection.primary_key_name - foreign_key = reflection.source_reflection.klass.primary_key + foreign_key = reflection.source_reflection.active_record_primary_key when :has_and_belongs_to_many table, join_table = table |