Rails 3.2.8
我有以下内容:
def index
params[:direction] ||= "desc"
params[:sort] ||= "status"
@products = product.solr_search( include: [:customer] ){
fulltext params[:query] if params[:query].present?
with :status, (params[:status] || params[:filter]) if (params[:status] || params[:filter]).present?
order_by( params[:sort], params[:direction] ) if params[:sort].present? && params[:direction].present?
paginate page: params[:page], per_page: params[:per_page]
}.results
end
我想做的是在status列='new'时以优先级进行初始排序。在MySQL中,它将是这样的:
SELECT * from product ORDER BY case when status = 'new'
知道我的语法应该是什么吗?