Ransack OR Requests

I want to search for all fields that are NULL or -1, using ransack.

search({:param_name_null => 1 }) 

will give zeros

 search({:param_name_is_any => -1 }) 

will give -1s

How to do OR between the two using ransack? Thanks

+6
source share
1 answer

Ransack Issue # 290 explains that such requests contain two separate conditions that must be specified separately, then combined.

I have not tested this snippet, but it, or something very similar, should work:

 .search(:m => 'or', :param_name_eq => -1, :param_name_null => true) 
+5
source

Source: https://habr.com/ru/post/944960/


All Articles