Pluck all the ID’s for the relation using the table’s primary key
Person.ids# SELECT people.id FROM peoplePerson.joins(:companies).ids# SELECT people.id FROM people INNER JOIN companies ON companies.person_id = people.id
# File activerecord/lib/active_record/relation/calculations.rb, line 205
def ids
pluck primary_key
end