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

蓝咒 提交于 2019-12-25 05:20:53

问题


This is similar to my previous question Ruby On Rails Active Admin has_many changing dropdown to use a different column

I figured out how to reassign a f.inputs but how would i go about reassigning the display of the data when viewing an item...

e.g:

Public Git Repo: https://github.com/gorelative/TestApp

Snippet of code i have in my 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

回答1:


Modify the show action

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


来源:https://stackoverflow.com/questions/10707308/ruby-on-rails-active-admin-has-many-changing-text-to-use-a-different-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!