Method: ActiveRecord::Reflection::ThroughReflection#association_primary_key
- Defined in:
- activerecord/lib/active_record/reflection.rb
#association_primary_key(klass = nil) ⇒ Object
We want to use the klass from this reflection, rather than just delegate straight to the source_reflection, because the source_reflection may be polymorphic. We still need to respect the source_reflection’s :primary_key option, though.
868 869 870 871 872 |
# File 'activerecord/lib/active_record/reflection.rb', line 868 def association_primary_key(klass = nil) # Get the "actual" source reflection if the immediate source reflection has a # source reflection itself actual_source_reflection.[:primary_key] || primary_key(klass || self.klass) end |