Activeadmin: boolean filter check_boxes do not work as expected

Created on 25 May 2013  路  3Comments  路  Source: activeadmin/activeadmin

given my model Page has a visible flag and I have the following filters

filter :name
filter :visible

accessing the Page AA shows the filters correctly. But I am not able to filter for Pages that are invisible, because leaving the checkbox untouched results in no parameter passed to meta_search. Maybe I'm missing something important here...

filters

Most helpful comment

Hi guys!

Is there a better way to make a single checkbox instead of two (with yes & no) if boolean field? I use some trick at the moment:

filter :garden, as: :check_boxes, collection: [['Garden', true]], label: ''

look at :garden case below:

screen shot 2015-04-21 at 09 41 46

All 3 comments

Yeah, that's the problem with checkboxes: there's only two possible values: on and off. For the boolean filter, off must mean "don't use this filter" otherwise it wouldn't act like all the other filters.

Instead of a checkbox we might want to have two radio buttons instead. Or maybe even three:

  • true
  • false
  • nil

since we changed to ransack, we now have a checkbox with yes/no/any int that case, I think we can close this

Hi guys!

Is there a better way to make a single checkbox instead of two (with yes & no) if boolean field? I use some trick at the moment:

filter :garden, as: :check_boxes, collection: [['Garden', true]], label: ''

look at :garden case below:

screen shot 2015-04-21 at 09 41 46

Was this page helpful?
0 / 5 - 0 ratings