繁体   English   中英

红宝石在轨道上-按两列排序结果

[英]ruby on rails- Order results by two columns

我有一个文章表(模型文章),我想按两个布尔列(:foreground,:on_evidence)进行排序,以便在视图中显示一些结果

在操作索引的视图控制器中:

class ShowController < ApplicationController
  def index
    @articles = Article.where("published = true ").order('foreground, on_evidence')
  end
end

这种方法是错误的...我该怎么办?

好的,我已经找到了解决方案,只是我更改了查找查询:

class ShowController < ApplicationController
  def index
    @articles = Article.where('published = true').order(foreground: :desc)
  end
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM