0

これは私の前の質問に似ていますRubyOnRails Active Admin has_manyドロップダウンを変更して、別の列を使用する

再割り当てする方法を理解しましたf.inputsが、アイテムを表示するときにデータの表示を再割り当てするにはどうすればよいですか...

例えば:

ここに画像の説明を入力してください

パブリックGitリポジトリ: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
4

1 に答える 1

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
于 2012-05-22T18:03:27.370 に答える