【发布时间】:2019-06-27 09:22:35
【问题描述】:
scope :not_null, -> (params) { where("data ILIKE 'string'", key: params['key']) }
我想要的是从 data 列或给定的字符串中检查
scope :not_null, -> { where("'random_string' ILIKE 'string'") }
我想要的范围必须支持我给出的列名或字符串,是否有可能拥有这样的范围
【问题讨论】:
-
在这种情况下,最好定义一个类方法而不是使用范围!
标签: sql ruby-on-rails activerecord