class Building < ActiveRecord::Base
class Floor < ActiveRecord::Base
I want to add a method to the Building model that returns the following:
Ideally I would like to make this chainable so that I could do the following:
Here is how what I am trying to get at looks like in postgresql:
array_agg(F.floor_number) AS numbers
buildings AS B
LEFT OUTER JOIN floors AS F ON
F.building_id = B.id
The following gives me the data I want but in a really crappy format (because of pluck). If I change pluck to select it breaks.
fields = "buildings.id, buildings.url"