我想做一些类似 SQL的事情AND
来为此添加第二个条件:
Article
.where("date_trunc('day', created_at) = ?", Date.yesterday-(params[:increment].to_i))
.order('articles.created_at DESC')
第二个条件是如果'site_id' attribute = "HIDE"
.
提前感谢您的任何提示。
我想做一些类似 SQL的事情AND
来为此添加第二个条件:
Article
.where("date_trunc('day', created_at) = ?", Date.yesterday-(params[:increment].to_i))
.order('articles.created_at DESC')
第二个条件是如果'site_id' attribute = "HIDE"
.
提前感谢您的任何提示。
只需添加另一个where
具有所需条件的子句:
Article
.where("date_trunc('day', created_at) = ?", Date.yesterday-(params[:increment].to_i))
.where(site_id: 'HIDE')
.order('articles.created_at DESC')
您可以AND
在where
语句中使用:
Article
.where("date_trunc('day', created_at) = ? AND site_id = 'HIDE'", Date.yesterday-(params[:increment].to_i))
.order("articles.created_at DESC")