如何在 rails active admin 索引页面的列表项中显示模型的多个属性项?
How to display multiple attributes items of a model in list item in rails active admin index page?
在具有多个属性的模型中,多对多关系在活动管理索引页中以逗号分隔显示。
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
在具有多个属性的模型中,多对多关系在活动管理索引页中以逗号分隔显示。
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