diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-08-14 18:05:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-14 18:05:51 -0400 |
commit | 2ffb12d457253ffa6f266f1649f71964df9006e0 (patch) | |
tree | b3ff7acce77324896bb681456d73918980dc5050 | |
parent | 8244a45e3ed083b0a9ef239a48095b3ddd81da11 (diff) | |
parent | 0e508e2b2f1d2d1a185b75e34bc53bc860996ad6 (diff) | |
download | rails-2ffb12d457253ffa6f266f1649f71964df9006e0.tar.gz rails-2ffb12d457253ffa6f266f1649f71964df9006e0.tar.bz2 rails-2ffb12d457253ffa6f266f1649f71964df9006e0.zip |
Merge pull request #30208 from kamipo/extract_primary_key_to_abstract_reflection
Extract `primary_key` to `AbstractReflection`
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 564dbcb342..b2c62cd686 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: @@ -1020,10 +1020,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 |