Ruby on rails I';我在has_scope gem上遇到了麻烦

Ruby on rails I';我在has_scope gem上遇到了麻烦,ruby-on-rails,ruby,Ruby On Rails,Ruby,我正在使用has_scope gem并尝试查找包含nil/not nil信息的列。它不起作用 我的模型中有两个作用域: scope :empty -> where(name: nil) scope :present -> where.not( title: nil) 在我的控制器中: has_scope :empty has_scope :present def index clients = apply_scopes(Clients).a

我正在使用has_scope gem并尝试查找包含nil/not nil信息的列。它不起作用

我的模型中有两个作用域:

 scope :empty -> where(name: nil)
 scope :present -> where.not( title: nil)
在我的控制器中:

    has_scope :empty
    has_scope :present

    def index
      clients = apply_scopes(Clients).all
    end
在命令行上:


curl-xget

忘记gem,直接使用作用域(正如大自然所希望的!)

另外,我不建议您使用单词“present”或“empty”作为作用域名称,因为这些单词是由ActiveRecord和Ruby集合保留的,例如

Client.last.appoiments.empty?
Client.last.present?

empty_name_clients = Client.empty

clients_with_names = Client.present