Ruby On Rails Active Admin has_many更改文本以使用其他列 [英] Ruby On Rails Active Admin has_many changing text to use a different column

查看:62
本文介绍了Ruby On Rails Active Admin has_many更改文本以使用其他列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这类似于我以前的问题



我在 fillups.rb


中的代码段

  ActiveAdmin.register填写做
表格做| f |
f.inputs做
f.input:car,:collection => Car.all.map {| car | [car.description,car.id]}
f.input:注释
f.input:cost
f.input:里程
f.input:gallons
f.buttons
结束
结束
结束


解决方案

修改 show 操作

  ActiveAdmin。注册Fillup do 
#...其他东西

show do
attribute_table do
#添加您的其他行
row:id
row :汽车|填充|
link_to fillup.car.description,admin_car_path(fillup.car)
结束
结束
结束
结束


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

解决方案

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

这篇关于Ruby On Rails Active Admin has_many更改文本以使用其他列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆