问题
In rails_admin, I've got a list of cities. Some have a numeric state_id
and some have a nil. I want my cities list view to let me filter based on whether that field is filled or blank.
How can I do that?
This raises an exception:
config.model 'City' do
list do
filters [:state_id]
...
... because rails_admin can't find "city_id" among its list of "filterable fields", even though it's one of the displayed fields.
回答1:
You have to set the field as filterable explicitly.
config.model 'City' do
list do
field :state_id do
filterable true
end
With that, I no longer needed the filters
setting.
来源:https://stackoverflow.com/questions/26179848/in-rails-admin-how-can-i-filter-based-on-the-presence-of-an-association-id