[英]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.