【发布时间】:2013-11-15 20:48:31
【问题描述】:
在我的应用程序中,我使用的是 has_scope gem。我已经制定了一些范围,他们正在努力在字段中查找字符串。 但现在我将添加一个新范围来查找特定参数为 nil 的所有记录 怎么做 ? 我找不到正确的语法,现在我在模型中有它:
student.rb
scope :connected, -> connected { where([:last_connected_at].nil?)}
student_controller.rb
class EtudiantsController < ApplicationController
has_scope :connected
def index
@students = apply_scopes(Student).all
end
end
application.html.erb
<%= link_to "Student never connected", "/etudiants?connected=false" %><br />
但它不起作用......
你能帮我吗?
尼古拉斯
【问题讨论】:
标签: ruby-on-rails scope has-scope