Ransack OR queries
Asked Answered
C

1

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

Cutcliffe answered 14/5, 2013 at 9:34 Comment(1)
ever find out how to do this?Lem
R
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)
Retortion answered 9/12, 2013 at 19:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.