在具有多个属性的模型中,来自多对多的关系在活动管理索引页面中以逗号分隔显示。
index do
# other columns goes here
column('Product Categories') { |p| p. product_categories.pluck(:category_title).join(', ') }
end
现在我要显示所有这些(category_title)
有什么建议吗?
由于您要在列表中打印,因此应使用以下内容:
index do
# other columns goes here
column('Product Categories') { |p| p.product_categories.pluck(:category_title).join('<br />').html_safe
end