[英]Filter by string instead of select in ActiveAdmin
I have belongs_to and has_many assotiations between two models. 我有两个模型之间的belongs_to和has_many assotiations。 By default, activeadmin using select input for it. 默认情况下,activeadmin使用select输入。 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? 做正确的最佳方法是什么?
ActiveAdmin uses MetaSearch , so you should be able to do ActiveAdmin采用元搜索 ,所以你应该能够做到
filter :items_<attribute>, as: :string
So in your case if the item has a name, you can do: 因此,如果项目有名称,您可以执行以下操作:
filter :items_name, as: :string
Refer relation of models and the following code 请参阅模型关系和以下代码
table = users id, name, email table =用户ID,姓名,电子邮件
table = customers id, name, user_id table = customers id,name,user_id
user has_many customers 用户has_many客户
customer belongs user 客户属于用户
USE filter :user_name, as: :string instead of filter :user USE过滤器:user_name,as :: string而不是filter:user
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.