aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-08-12 19:13:15 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-08-12 19:13:15 +0900
commit0e508e2b2f1d2d1a185b75e34bc53bc860996ad6 (patch)
treef44eba30a38811fdc9ff00aec56cde53c39746bd /activerecord/lib
parent98360a96cc1e0bb6ab9eb31f421a36439e66eefc (diff)
downloadrails-0e508e2b2f1d2d1a185b75e34bc53bc860996ad6.tar.gz
rails-0e508e2b2f1d2d1a185b75e34bc53bc860996ad6.tar.bz2
rails-0e508e2b2f1d2d1a185b75e34bc53bc860996ad6.zip
Extract `primary_key` to `AbstractReflection`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/reflection.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index d044f9dfe8..f859675df2 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -329,6 +329,10 @@ module ActiveRecord
def join_pk(_)
foreign_key
end
+
+ def primary_key(klass)
+ klass.primary_key || raise(UnknownPrimaryKey.new(klass))
+ end
end
# Base class for AggregateReflection and AssociationReflection. Objects of
@@ -697,10 +701,6 @@ module ActiveRecord
def derive_join_table
ModelSchema.derive_join_table_name active_record.table_name, klass.table_name
end
-
- def primary_key(klass)
- klass.primary_key || raise(UnknownPrimaryKey.new(klass))
- end
end
class HasManyReflection < AssociationReflection # :nodoc:
@@ -1024,10 +1024,6 @@ module ActiveRecord
end
end
- def primary_key(klass)
- klass.primary_key || raise(UnknownPrimaryKey.new(klass))
- end
-
def inverse_name; delegate_reflection.send(:inverse_name); end
def derive_class_name