在活动管理员中映射“has_many”

Mapping `has_many` in active admin

我正在尝试从活动管理员的索引视图中的 ID 数组映射 name 属性。

我有

扇区模型

has_many :portfolio_sectors
has_many :portfolios, through: :portfolio_sectors

投资组合模型

has_many :portfolio_sectors
has_many :sectors, through: :portfolio_sectors

投资组合部门

belongs_to :portfolio
belongs_to :sector

在活跃的管理员中,目前,我有

# Index
index do
  selectable_column
  column :sector_ids
  actions
end

这将 return

[2, 3]

我有扇区的 ID。如何显示 name 属性?使用 map 给我

undefined method `map` for fixnum 2

如何访问 name

accepts a block.

column "Sectors" do |portfolio|
  portfolio.sectors.map(&:name)
end