aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-03-03 14:19:43 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2017-03-03 14:19:43 -0800
commit4be42720e416ceb0ed7c685b311fe91b17d4c93f (patch)
tree499fae85a0500512ea02bd832a65e5883e5379f4 /activerecord
parentc8e946683536e2555f98e0fa401b5a9721a9a6cb (diff)
downloadrails-4be42720e416ceb0ed7c685b311fe91b17d4c93f.tar.gz
rails-4be42720e416ceb0ed7c685b311fe91b17d4c93f.tar.bz2
rails-4be42720e416ceb0ed7c685b311fe91b17d4c93f.zip
refactor so there is only one JoinKeys factory method
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/reflection.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index ba40db2de9..36c757e155 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -173,7 +173,15 @@ module ActiveRecord
JoinKeys = Struct.new(:key, :foreign_key) # :nodoc:
def join_keys(association_klass)
- JoinKeys.new(foreign_key, active_record_primary_key)
+ JoinKeys.new(join_pk(association_klass), join_fk)
+ end
+
+ def join_pk(klass)
+ foreign_key
+ end
+
+ def join_fk
+ active_record_primary_key
end
# Returns a list of scopes that should be applied for this Reflection
@@ -711,9 +719,12 @@ module ActiveRecord
end
end
- def join_keys(association_klass)
- key = polymorphic? ? association_primary_key(association_klass) : association_primary_key
- JoinKeys.new(key, foreign_key)
+ def join_fk
+ foreign_key
+ end
+
+ def join_pk(klass)
+ polymorphic? ? association_primary_key(klass) : association_primary_key
end
def join_id_for(owner) # :nodoc: