10

I want to make a search for all fields that are NULL or have the value of -1 using ransack.

search({:param_name_null => 1 }) 

will give the nulls

search({:param_name_is_any => -1 })

will give the -1s

How do i make an OR between these two using ransack? Thanks

aharonidan
  • 183
  • 1
  • 5

1 Answers1

9

Ransack Issue #290 explains that queries like this contain two separate conditions which need to be specified separately then combined.

I haven't tested this snippet but it, or something very much like it, should work:

.search(:m => 'or', :param_name_eq => -1, :param_name_null => true)
Josh Rumbut
  • 2,640
  • 2
  • 32
  • 43