I\'ve a table with an integer column called \"map_id\", I want to add an activeadmin filter to filter if this column IS NULL or IS NOT NULL.
How could this be implem
The new version of ActiveAdmin uses Ransacker. I manage to got it working this way:
filter :non_nil_map_id, :label => 'Assigned', :as => :select, :collection => [['none', 'none'], ['one', 1],['tow', 2]]
For consistency, I took the same code from @Gret answer just changing the filter name
ransacker :not_nil_map_id, :formatter => proc {|id| map_id != 'none' ? id : 'none' } do |parent|
parent.table[:id]
end
This should trigger a search against nil in case the id is 'none', and active record will return all the nil id entries.
This thread helped a lot.