How to get the latest record from each group in ActiveRecord?

后端 未结 5 2001
暖寄归人
暖寄归人 2020-12-14 01:07

In my Ruby on Rails application I have a database structure like this:

Project.create(:group => \"1\", :date => \"2014-01-01\")
Project.create(:group =         


        
5条回答
  •  醉话见心
    2020-12-14 01:31

    Project.where(:group => "1", :date => "2014-01-01").last
    

    .last is what you are looking for.

提交回复
热议问题