[英]Filter by string instead of select in ActiveAdmin
我有两个模型之间的belongs_to和has_many assotiations。 默认情况下,activeadmin使用select输入。 但就我而言,这是不可能的 - 因为我有成千上万的物品。 当我尝试更改过滤器时
filter :item, as: :string
它说
undefined method `item_id_contains' for #<MetaSearch::Searches::DeliveryTime:0x007fdd57f12db8>
做正确的最佳方法是什么?
ActiveAdmin采用元搜索 ,所以你应该能够做到
filter :items_<attribute>, as: :string
因此,如果项目有名称,您可以执行以下操作:
filter :items_name, as: :string
请参阅模型关系和以下代码
table =用户ID,姓名,电子邮件
table = customers id,name,user_id
用户has_many客户
客户属于用户
USE过滤器:user_name,as :: string而不是filter:user
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.