Set the default search type for Active Sidebars Active Admin gem

I use the ActiveAdmin rails attribute and have several filters configured for one of my models. For one of the string filters, I would like to set a drop-down list of the search type ("Contains", "Equals", "Start with", "Ends with") by default, "Equals" instead of "Contains".

Also, similarly, I would like to set the default value of “Big Than” instead of “Equals” for one of my numerical filters.

Here's the corresponding configuration ...

filter :message filter :likes_count, as: :numeric 
+7
filter ruby-on-rails activeadmin
source share
1 answer

This will solve the second problem, and you should use the same template to fix the first.

 filter :likes_count, as: :numeric, filters: ['gt', 'lt', 'eq'] 

Where gt is greater than lt, less, eq is equal. You can change or delete everything that you do not need. You will need to make sure that you have the translation setting in the 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" 
+6
source share

All Articles