如何在控制台上快速进行字段通配符搜索? 我不需要防止SQL注入。
我正在使用PostgreSQL。
搜索包含“emerging”的字符串的title
。
这个方法可以工作,但有点麻烦。 不知道是否有简写方法?
Product.where("title @@ :q", q: "emerging")
同样笨重的方法,在Rails 4中似乎已经不再适用于我:
Product.where("title ILIKE ?", "emerging")
Product.where("title ilike :q", q: "emerging")
我猜我正在寻找像
Product.where(title: "*emerging*")
这样的东西。