如何在ActiveAdmin中向现有字符串过滤器添加OR?

时间:2012-03-16 15:34:16

标签: ruby-on-rails-3 ruby-on-rails-3.1 filter activeadmin

我需要能够在字符串过滤器中搜索ActiveAdmin 0.4.0的多个术语。

e.g。

filter :city, :as => :string

如何更改此设置以便能够搜索“纽约”或“洛杉矶”或“底特律”等字词?

1 个答案:

答案 0 :(得分:1)

你想要那个:

filter :city, :as => :string, :match => 'New York', :or => :match => 'Los Angeles', :or => :match => 'Detroit'

‘match’ will check if a field, when turned into a string, matches a given regular expression.

‘smatch’ works the same but only accepts fields that are strings.

更多信息here