Filter by string instead of select in ActiveAdmin
Asked Answered
W

2

9

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?

Waterlog answered 2/4, 2013 at 23:12 Comment(0)
K
21

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
Kahl answered 2/4, 2013 at 23:20 Comment(1)
Isn't metasearch anymore, it's using Ransack(github.com/activerecord-hackery/ransack) but the answe is still valid. Thanks.Heptateuch
L
0

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

Lindquist answered 5/1, 2016 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.