Implements the ids reader
method, e.g. foo.item_ids for Foo.has_many :items
# File activerecord/lib/active_record/associations/collection_association.rb, line 45
def ids_reader
if loaded? || options[:finder_sql]
load_target.map do |record|
record.send(reflection.association_primary_key)
end
else
column = "#{reflection.quoted_table_name}.#{reflection.association_primary_key}"
scoped.select(column).except(:includes).map! do |record|
record.send(reflection.association_primary_key)
end
end
end