Set dropdown search type default for Active Admin gem sidebar filters
activeadmin, filter, ruby-on-rails
Solution
This would solve the second one and you should be able to use the same pattern to fix the first.
filter :likes_count, as: :numeric, filters: ['gt', 'lt', 'eq']
Where gt is greater than, lt less than, eq is equal. You can rearrange or remove any you don't need. You will need to make sure you have a translation setup in your en.yml file
So in your config/locales/en.yml
en:
active_admin:
filters:
predicates:
predicates:
contains: "Contains"
equals: "Equals"
eq: "Equals"
starts_with: "Starts with"
ends_with: "Ends with"
greater_than: "Greater than"
gt: "Greater than"
less_than: "Less than"
lt: "Less than"
Problem
I am using the ActiveAdmin rails gem and have several filters configured for one of my models. For one of the string filters I would like to set the search type dropdown ("Contains", "Equals", "Starts with", "Ends with") to default to "Equals" instead of "Contains". Also, similarly I would like to set one of my numeric filters to default to "Greater Than" instead of "Equals". Here's the relevant configuration... ``` filter :message filter :likes_count, as: :numeric ```