diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-31 20:00:24 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-12-31 20:00:45 +0000 |
commit | 12675988813e82ac30f7c0e0008c12c4cf5d8cdc (patch) | |
tree | 2856d3a21a139d0c182fc5a99724dc49e39d7eb5 /activerecord/lib/active_record/associations/through_association.rb | |
parent | 3c400627eb9cfac380d716ccf1182d61db4a45a6 (diff) | |
download | rails-12675988813e82ac30f7c0e0008c12c4cf5d8cdc.tar.gz rails-12675988813e82ac30f7c0e0008c12c4cf5d8cdc.tar.bz2 rails-12675988813e82ac30f7c0e0008c12c4cf5d8cdc.zip |
Rename AssociationReflection#primary_key_name to foreign_key, since the options key which it relates to is :foreign_key
Diffstat (limited to 'activerecord/lib/active_record/associations/through_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index 65ca4b1282..c78f5d969f 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -13,7 +13,7 @@ module ActiveRecord def stale_target? if @target && @reflection.through_reflection.macro == :belongs_to && defined?(@through_foreign_key) previous_key = @through_foreign_key.to_s - current_key = @owner.send(@reflection.through_reflection.primary_key_name).to_s + current_key = @owner.send(@reflection.through_reflection.foreign_key).to_s previous_key != current_key else @@ -69,14 +69,14 @@ module ActiveRecord if @reflection.source_reflection.macro == :belongs_to reflection_primary_key = @reflection.source_reflection.options[:primary_key] || @reflection.klass.primary_key - source_primary_key = @reflection.source_reflection.primary_key_name + source_primary_key = @reflection.source_reflection.foreign_key if @reflection.options[:source_type] column = @reflection.source_reflection.options[:foreign_type] conditions << right[column].eq(@reflection.options[:source_type]) end else - reflection_primary_key = @reflection.source_reflection.primary_key_name + reflection_primary_key = @reflection.source_reflection.foreign_key source_primary_key = @reflection.source_reflection.options[:primary_key] || @reflection.through_reflection.klass.primary_key if @reflection.source_reflection.options[:as] @@ -100,7 +100,7 @@ module ActiveRecord raise ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(@owner, @reflection) if [:has_one, :has_many].include?(@reflection.source_reflection.macro) join_attributes = { - @reflection.source_reflection.primary_key_name => + @reflection.source_reflection.foreign_key => associate.send(@reflection.source_reflection.association_primary_key) } @@ -159,7 +159,7 @@ module ActiveRecord def update_stale_state if @reflection.through_reflection.macro == :belongs_to - @through_foreign_key = @owner.send(@reflection.through_reflection.primary_key_name) + @through_foreign_key = @owner.send(@reflection.through_reflection.foreign_key) end end end |