Mit*_*tch 5 ruby-on-rails activeadmin
我有包,有多个组件(使用has_many通过Bundles链接)
在ActiveAdmin中,当我显示一个包时,我希望能够显示链接到它的所有组件
所以我有一个show方法如下:
show do
attributes_table do
row :description
row 'Components' do |n|
package.components.each do |component|
#debugger
component.name
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我显示页面时,它会显示每个记录的完整版本,即(其中一个我在下面显示,但会有尽可能多的组件):
[#<Component id: 2, component_token: "6e9be0b0-71c0-012f-d523-00254bca74c4", name: "Exercise Module", description: "This is the exercise module", created_at: "2012-04-26 11:25:20", updated_at: "2012-04-26 11:25:20">]
Run Code Online (Sandbox Code Playgroud)
当我在调试它的位置停止调试器时,component.name的值被赋予"练习模块",但这不是输出到节目的内容 - 事实上,ActiveAdmin似乎忽略了该组件中的所有内容| 块.
如何显示记录属性,而不是整个记录本身?
谢谢
alo*_*ony 16
它正在发生,因为该行显示了该行的输出,package.components.each {|component| ... }而这是该集合
试试这个:
show do
attributes_table do
row :description
row 'Components' do |n|
package.components.map(&:name).join("<br />").html_safe
end
end
end
Run Code Online (Sandbox Code Playgroud)
或者你喜欢的任何其他连接字符串:)
| 归档时间: |
|
| 查看次数: |
6807 次 |
| 最近记录: |