【问题标题】:Ruby On Rails Active Admin has_many changing text to use a different columnRuby On Rails Active Admin has_many 更改文本以使用不同的列
【发布时间】:2012-05-22 17:50:33
【问题描述】:

这和我之前的问题Ruby On Rails Active Admin has_many changing dropdown to use a different column类似

我想出了如何重新分配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

【问题讨论】:

  • 查看我的repos 以获取更多 ActiveAdmin 示例...并不是说它们是完美的...

标签: ruby-on-rails ruby activeadmin


【解决方案1】:

修改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

【讨论】:

  • Kyle,你能回答几个关于这个的快速问题吗?
  • 我要去开会了。检查我的 SO 个人资料和 gmail 聊天我,我会回复你。
猜你喜欢
  • 1970-01-01
  • 2019-04-25
  • 1970-01-01
  • 2015-01-08
  • 2016-11-29
  • 2013-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多