ActiveAdmin belongs_to 索引显示关联字段

ActiveAdmin belongs_to index show associated field

试图显示嵌套字段而不仅仅是 ID。 例如,product_catergory_id 不是显示外键 1,而是显示 product_catergories/product_catergory 中的 "Computers"(table/field id 1)。 f.inputs 上似乎有很多信息,但专栏上没有。

product
belongs_to :product_catergories
(has all the foreign keys)


product_catergories
has_many : products

app/admin/products.rb  --partial  

index do
    selectable_column
    #my stuff here
    column :name
    column :product_description
    column :product_catergory_id
    column :product_colour_id
    column :product_size_id
    column :supplier_id
    actions
  end
找到解决方案

 index do
    selectable_column
    #my stuff here
    column :name
    column :product_description
    column :product_catergory_id
    column "product_catergory_id" do |i|
      i.product_catergory.product_catergory
    end
    column :product_colour_id
    column :product_size_id
    column :supplier_id
    actions
  end

index do
    selectable_column
    #my stuff here
    column :name
    column :product_description
    column :product_catergory_id
    column "product_catergory_id" do |i|
      i.product_catergory.product_catergory
    end
    column :product_colour_id
    column :product_size_id
    column :supplier_id
    actions
  end