module ActiveRecord::AttributeMethods::CompositePrimaryKey

def id_in_database

returns an array of primary key column values from database.
Returns the primary key column's value from the database. If the primary key is composite,
def id_in_database
  if self.class.composite_primary_key?
    @primary_key.map { |col| attribute_in_database(col) }
  else
    super
  end
end