我有一篇文章表(模型文章),我想通过两个布尔列(:foreground,:on_evidence)订购,以便在视图中显示一些结果
在动作索引中的视图的控制器中:
class ShowController < ApplicationController
def index
@articles = Article.where("published = true ").order('foreground, on_evidence')
end
end
这种方法错了......我该怎么办呢?
答案 0 :(得分:0)
好的,我发现解决方案只是我改变了查询查询:
class ShowController < ApplicationController
def index
@articles = Article.where('published = true').order(foreground: :desc)
end
end