如何在rails active admin index page中的列表项中显示模型的多个属性项?

问题描述 投票:-1回答:1

在具有多个属性的模型中,来自多对多的关系在活动管理索引页面中以逗号分隔显示。

index do
  # other columns goes here
  column('Product Categories') { |p| p. product_categories.pluck(:category_title).join(', ') }
end

现在我要显示所有这些(category_title)

有什么建议吗?

ruby-on-rails ruby-on-rails-4 ruby-on-rails-5 activeadmin
1个回答
1
投票

由于您要在列表中打印,因此应使用以下内容:

index do
  # other columns goes here
  column('Product Categories') { |p| p.product_categories.pluck(:category_title).join('<br />').html_safe
end
© www.soinside.com 2019 - 2024. All rights reserved.