Rails 和活动管理员嵌套资源

Rails and Active Admin Nested Resources

我构建了一个简单的电子商务应用程序,并且我正在为管理面板使用 active admin。我的问题是这样的。

我有两个模型订单 & order_items。 order_items 保存订单产品。关联是 order -> has_many order_items & order_items -> belongs_to orders。

我在活动管理员中有此代码,但我看不到订单项(空白)。

 index :title => 'orders' do
  selectable_column
  id_column
  column "value", :subtotal
  column "tax", :tax
  column "shipping", :shipping
  column "total value", :total
  column "status", :order_status_id 
  column "created_at", :created_at 
  column "updated_at", :updated_at
  column "order_items", :order_items
  actions
end

我可以到达 order_items 抛出控制台,所以模型关联没有问题。

按照以下方式尝试:

index :title => 'orders' do
  selectable_column
  id_column
  column "value", :subtotal
  column "tax", :tax
  column "shipping", :shipping
  column "total value", :total
  column "status", :order_status_id 
  column "created_at", :created_at 
  column "updated_at", :updated_at
  column :order_items, sortable: true do | item |
    item.id # this could be any attribute attached to the order_item table 
  end
  actions
end