将所有关联列为活动管理中的链接

List all associations as links in active admin

是否可以在活动管理员中将我记录的所有 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