简体   繁体   中英

Trying to implement 'contains' filter on ActiveAdmin rails

Some had posted similar question as mine. I tried the solution to most of them. Some say ActiveAdmin is using Metasearch and some say it's using ransack. I tried both methods. My activeadmin version is 1.0.0.pre4 and rails 4.2.6 Follwing is my code for the user based filter:

ActiveAdmin.register Equipment do
    filter :user
end 

This gives me a user dropdown where I can select one of the user and it filters the result based on that user. Right now I have only 3 users so its fine. But in future it will grow to thousands. So instead I would like to have a contains field, where I can enter user name and filter. I tried changing to following:

filter :user, as: :string, label: 'User' 

and also

filter :items_user, as: :string

Didn't work. Can somebody please tell me what am I missing?

Try this,

filter :user_name, as: :string

where name is attribute of User Model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM