2

I'm using Globalize and ActiveAdmin, and I've now installed a gem from a fork of ActiveAdminGlobalize

Everything that is described in the readme is working, but I'd like to add a filter to the Active Admin Index.

So, for the model stuff.rb

class Stuff < ApplicationRecord
  translates :name
  active_admin_translates :name do
    validates_presence_of :name
  end
end

And the class in app/admin/stuff.rb

ActiveAdmin.register Stuff do
  index do
    translation_status
    column :name 
  end

  filter :name

end

How do I make the filter :name to work?

Thanks

Tiago
  • 673
  • 1
  • 8
  • 24

1 Answers1

5

I'm using the regular ActiveAdmin gem and, after scratching my head for quite some time, found that the following works:

filter :translations_name_contains, as: :string

Of course you can change name with any other attributes you have translated with Globalize

filter :translations_title_contains, as: :string

To tie everything up nicely, I like to customize the label to avoid the default one AA creates:

filter :translations_title_contains, as: :string, label: "Search", placeholder: "Search page title..."

Hope this helps, thanks!

rorofromfrance
  • 1,854
  • 12
  • 21
  • It's not exactly what I was looking for, cause I'd like to keep the dropdown list, but still it helps. Thanks! – Tiago Aug 21 '17 at 10:31
  • What dropdown list are you referring to @Tiago ? – rorofromfrance Aug 28 '17 at 12:12
  • Usually, when having a filter for countries, I prefer to have a dropdown list with the names of the existing countries, instead of a search box to look for them, @rorofromfrance – Tiago Sep 01 '17 at 11:32