问题
I have a simple filter in ActiveAdmin for boolean value. It looks like this
filter :invisible, as: :select
You may choose "any", "true" or "false" and it works just fine. But the default value of the filter is "any", while I need to set it to "true". How can I do it? Thank you.
回答1:
try some like this :
filter : invisible, as: :select, collection: [["Yes", true], ["No", false]]
This works fine for me.
Obviously you can edit the "Yes"
- "No"
string as you want.
回答2:
I've found an answer. You have to use before_filter
so it is as simple as
controller do
before_filter invisible: :index do
params[:q] = {invisible_eq: true} if params[:commit].blank?
end
end
来源:https://stackoverflow.com/questions/24335297/set-activeadmin-filter-default-value