是否可以在事件管理员中列出所有 has_many
将我的记录关联为链接?
代码应该类似于:
column "belongs to" do |b|
b.associations.map { |a| link_to(a.name, admin_association_path(a) }
end
但这会生成一个未呈现为可点击链接的标签列表。
最佳答案
map
正在生成一个 html 字符串数组,因此您需要 join
他们获取单个字符串,然后将其标记为 html 安全。
column "belongs to" do |b|
b.associations
.map { |a| link_to(a.name, admin_association_path(a)) }
.join
.html_safe
end
关于ruby-on-rails - 列出所有关联作为事件管理中的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32618865/