method
active_record_primary_key
v7.1.3.4 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Reflection::AssociationReflection
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
active_record_primary_key()
public
Hide source
# File activerecord/lib/active_record/reflection.rb, line 537 def active_record_primary_key custom_primary_key = options[:primary_key] @active_record_primary_key ||= if custom_primary_key if custom_primary_key.is_a?(Array) custom_primary_key.map { |pk| pk.to_s.freeze }.freeze else custom_primary_key.to_s.freeze end elsif active_record.has_query_constraints? || options[:query_constraints] active_record.query_constraints_list elsif active_record.composite_primary_key? # If active_record has composite primary key of shape [:<tenant_key>, :id], infer primary_key as :id primary_key = primary_key(active_record) primary_key.include?("id") ? "id" : primary_key.freeze else primary_key(active_record).freeze end end