How to specify a less than today condition on a date in rails active record

前端 未结 2 1173
独厮守ぢ
独厮守ぢ 2021-02-02 06:49

I\'m trying to figure out how to pull all the records in my set where their fields \"publish\" is true and \"expires\" is less than today. I have the following but i dont think

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-02 07:37

    Try this:

    @announcements = Announcement.where("publish = ? AND expires < ?", true, Date.today)
    

提交回复
热议问题