Ruby On Rails Active Admin has_many changing dropdown to use a different column

后端 未结 2 810
不知归路
不知归路 2021-01-06 09:30

I am completely new to ActiveAdmin and RoR and i cant figure out how to change the visible value of the dropdowns in a has_many association.

Fillup Model



        
2条回答
  •  萌比男神i
    2021-01-06 10:07

    Something like this should work...

    In app/admin/model_name.rb

    form do |f|
      f.inputs "My Model Name" do
        # add your other inputs
        f.input :cars, :collection => Car.all.map{ |car| [car.description, car.id] }
        f.buttons
      end 
    end
    

    Read this article to learn more about modifying the form.

    AciveAdmin uses formtastic, you should read about that as well.

提交回复
热议问题