Method: ActiveRecord::AttributeMethods::CompositePrimaryKey#id

Defined in:
activerecord/lib/active_record/attribute_methods/composite_primary_key.rb

#idObject

Returns the primary key column’s value. If the primary key is composite, returns an array of the primary key column values.



8
9
10
11
12
13
14
# File 'activerecord/lib/active_record/attribute_methods/composite_primary_key.rb', line 8

def id
  if self.class.composite_primary_key?
    @primary_key.map { |pk| _read_attribute(pk) }
  else
    super
  end
end