platanus / activeadmin_addons

Extends ActiveAdmin to enable a set of great optional UX improving add-ons
MIT License
763 stars 288 forks source link

Add primary_key option to search select #485

Open cprodhomme opened 1 year ago

cprodhomme commented 1 year ago

for activeadmin_addons v1

Motivation / Background

I have this architecture :

Account User Item

Item -> UserItem -> User -> Account

I want to filter Item and search only on Account url like this :

  filter :user_id,
         as: :search_select_filter,
         url: proc { admin_accounts_path },
         fields: %i(email),
         display_name: "email",
         minimum_input_length: 2,
         order_by: "email_asc",
         primary_key: "user_id"

(obviously, to do that, i have add user_id in the json response of accounts#index)

Detail

This Pull Request add primary_key option for search select

Additional information

Checklist

Before submitting the PR make sure the following are checked:

cprodhomme commented 1 year ago

I can made another PR for the v2 if you want with the same usage