1

I have a question: how do i write 2 conditions in filters params? :page_path.eql => "/teams/1" or :page_path.eql => 'teams/2'

it works for one condition, but dont work with two:(

output = Exits.results(profile, :filters => {:page_path.eql => "/teams/1"})
Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
Tran duy Khoa
  • 59
  • 1
  • 1
  • 6

1 Answers1

0

Try this

output = Exits.results(profile,:filters =>{:page_path.contains => "^/teams/[1|2]$"})

you can also try shorthand

output = profile.exits(:filters =>{:page_path.contains => "^/teams/[1|2]$"})

with date options

output = Exits.results(profile, :filters => {:page_path.contains => "^/teams/[1|2]$"},:start_date => Date.new(2012,8,13),:end_date => Date.today)

or

output = profile.exits(:filters => {:page_path.contains => "^/teams/[1|2]$"},:start_date => Date.new(2012,8,13),:end_date => Date.today)

This works for me

use contains instead of matches I think it does not understand regex.

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
  • It isn't work! I was try `output = Exits.results(profile, :filters => {:page_path.matches => "/admin/teams/1", "/admin/teams/23"},:start_date => Date.new(2012,8,13),:end_date => Date.today)``output = Exits.results(profile, :filters => {:page_path.matches => "/admin/teams/#{'1'||'23'}"},:start_date => Date.new(2012,8,13),:end_date => Date.today) ``output = Exits.results(profile, :filters => {:page_path.matches => "/admin/teams/#{'1','2'}"},:start_date => Date.new(2012,8,13),:end_date => Date.today) ` and your idea but nothing matches – Tran duy Khoa Aug 16 '12 at 03:37
  • @TranduyKhoa ,use contains instead of matches I think it does not understand regex. check updated answer – Pritesh Jain Aug 16 '12 at 05:32
  • what output for this `profile.exits(:filters => {:page_path.contains => "/admin/teams/[1|2]"},:start_date => Date.new(2012,8,13),:end_date => Date.today)` – Pritesh Jain Aug 17 '12 at 11:22
  • #, # no result. I wanna make a query to get `team/1 and /2 only`! Any way, thanks for your help:) – Tran duy Khoa Aug 20 '12 at 09:54
  • @TranduyKhoa I got waht you want I have updated answer hope that helps. use regex "^query$" to limit out search – Pritesh Jain Aug 20 '12 at 13:58