I'm using https://github.com/sferik/rails_admin to handle my admin interface.
It's possible to filter your model based on the current columns that exists in this model (id, created_at etc.)
I want to be able to add custom filters for associations.
For example:
When I'm exploring the "Towns" model I want to be able to show only towns that have one or more projects.
I could do this by adding a new column to towns, called has_projects as a boolean that will be set to true when there are 1 or more projects associated, but I feel there must be a cleaner way to make your own custom filters ?
You can try using enum. See https://github.com/sferik/rails_admin/wiki/Enumeration
I used for belongs_to association, like following:
field :partner_id, :enum do
enum do
Partner.all.collect {|p| [p.name, p.id]}
end
end
And in list view, added:
list do
filters [:partner_id]
...
end
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