这与我之前的问题Ruby On Rails Active Admin has_many changing dropdown to use a different column
类似我想出了如何重新分配f.inputs
,但在查看项目时如何重新分配数据的显示......
e.g:
Public Git Repo:https://github.com/gorelative/TestApp
我在fillups.rb
ActiveAdmin.register Fillup do
form do |f|
f.inputs do
f.input :car, :collection => Car.all.map{ |car| [car.description, car.id] }
f.input :comment
f.input :cost
f.input :mileage
f.input :gallons
f.buttons
end
end
end
答案 0 :(得分:2)
修改show
操作
ActiveAdmin.register Fillup do
# ... other stuff
show do
attributes_table do
# add your other rows
row :id
row :car do |fillup|
link_to fillup.car.description, admin_car_path(fillup.car)
end
end
end
end