ActiveAdmin: Dropdown too big when editing model instance

前端 未结 1 1382
迷失自我
迷失自我 2021-01-25 17:58

I have two models: UserDevice and UserInfo as follows (in schema.rb):

  create_table \"user_devices\", force: :cascade do |t|
    t.int         


        
相关标签:
1条回答
  • 2021-01-25 18:43

    Yes. Check out chosen_rails gem.

    Make sure to follow installation recommendations carefully (i.e. requiring js's, css's and so on).

    Your user_info input will look something like this:

    f.input :user_info,
      collection: -> { UserInfo.pluck(:id, :email) },
      input_html: { class: 'chosen-select' } 
    

    Here is an example as per docs:

    f.association :user_info, 
      collection: UserInfo.pluck(:id, :email),
      include_blank: true,
      input_html: { class: 'chosen-select' }
    

    But I do not remember if Formtastic has f.association.

    You should try different compositions of these two examples. What it would do, is you will start type email (you can pick any other attribute) and it will immediately pick only these, which are matching to already typed letters.

    0 讨论(0)
提交回复
热议问题