postgresql - Rails joins value from association -
i have 2 model group , item
class group < activerecord::base has_many :items end class item < activerecord::base belongs_to :group end
my query
group.joins(:items).select('items.created_at item_created_at, groups.*').where("items.created_at > ?", time)
i need load uniq groups field 'item_created_at' max(items.created_at)
do mean like: group.joins(:items).select('max(items.created_at), groups.*').references(:items) ?
not sure if want, think fetch groups , newest items' created_at.
Comments
Post a Comment