This question is related to the ActiveAdmin gem. I'm trying to filter a column that has a boolean type but with no success: filter :column_name
and filter :column_name, :as => :boolean
don't work.
Any idea?
Thanks!
filter :column_name, :as => :select
will create a drop down with values "Any", "True", "False"
As of ActiveAdmin 0.6.2, using filter :column_name, as: :select
now has the horrible side effect of doing a complete table scan. Plus, its options are now "Any", "true", "false".
For example, if I have a District
model with the boolean column enabled
then filter :enabled, as: :select
generates the query SELECT DISTINCT "districts"."enabled" FROM "districts" ORDER BY enabled asc
to obtain the 3 values. My districts table is quite large, so this is clearly not what I want.
OTOH, while I can now use filter :column_name, as: :boolean
, it uses a checkbox that defaults to not being checked, which is again not what I want.
To restore the pre-0.6.2 behavior, I had to do this: filter :enabled, as: :select, collection: [["Yes", true], ["No", false]]
. ActiveAdmin drops in the "Any" value for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With