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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -