我有一堆事件,我想基于两列来提取它们。我需要将“发布”列设置为“特色”,并且我需要start_on列大于或等于今天的日期。
目前我有:
@featured_events = Event.where(publish: "Featured", ['start_on >= ?', Date.today]).all.sort_by &:start_on
我尝试了很多变种,但没有运气。
谢谢!
编辑::而我正在推动的数据库是mongo。 mongo是否限制'where'子句使用的参数数量?
答案 0 :(得分:1)
@featured_events = Event
.where("publish = 'Featured' AND start_on >= ?", Date.today)
.order(:start_on).all
或使用2次where
来电:
@featured_events = Event
.where(publish: 'Featured')
.where("start_on >= ?", Date.today)
.order(:start_on).all
答案 1 :(得分:0)