Meliborn
Meliborn

Reputation: 6645

Filter by string instead of select in ActiveAdmin

I have belongs_to and has_many assotiations between two models. By default, activeadmin using select input for it. But in my case, it's imposible - because I have a thousands items. When I trying change filter to

filter :item, as: :string

it says that

undefined method `item_id_contains' for #<MetaSearch::Searches::DeliveryTime:0x007fdd57f12db8>

What is the best way to do it right?

Upvotes: 9

Views: 4098

Answers (2)

Inx Maurya
Inx Maurya

Reputation: 1155

Refer relation of models and the following code

table = users id, name, email

table = customers id, name, user_id

user has_many customers

customer belongs user

USE filter :user_name, as: :string instead of filter :user

Upvotes: 0

Lu&#237;s Ramalho
Lu&#237;s Ramalho

Reputation: 10208

ActiveAdmin uses MetaSearch, so you should be able to do

filter :items_<attribute>, as: :string

So in your case if the item has a name, you can do:

filter :items_name, as: :string

Upvotes: 21

Related Questions