Edwin Liang
Edwin Liang

Reputation: 126

How do I add an OR to an existing string filter in ActiveAdmin?

I need to be able to search by multiple terms in a string filter for ActiveAdmin 0.4.0.

e.g.

filter :city, :as => :string

How can I change this to be able to search for terms such as 'New York' OR 'Los Angeles' OR 'Detroit' ?

Upvotes: 0

Views: 167

Answers (1)

ihmabreu
ihmabreu

Reputation: 19

you want that:

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.

more info here

Upvotes: 1

Related Questions