I've trying to do a mongoid query in my rails project. I thought this should work but it returns RegexpError: unmatched close parenthesis: /)/i This is my attempt
search = params[:name]
users = User.any_of({first_name: /#{search}/i}, { last_name: /#{search}/i}).to_a
I really dont know what I'm doing wrong. Any help appreciated
/#{Regexp.escape(search)}/i