客户和订单有2种型号。客户有很多订单。是否可以将订单显示为客户的成员。网址示例:
本地主机:3000 /管理/客户/ 1 /订单
此网址会显示客户1过滤的订单型号索引页。
这可以通过使用自定义操作来实现,但我需要在订单索引页面中使用“批处理操作”功能。 table_for未创建“批处理操作”按钮。
答案 0 :(得分:0)
是的,嵌套路线。
的routes.rb
resources :customers do
resources :orders
end
customer.rb
accepts_nested_attributes_for :orders
orders_controller.rb
def index
@customer = Customer.find(params[:customer_id])
@orders = @customer.orders.all
end
路由(没有任何管理员命名空间)类似于customer_orders_path(customer)
。
之前我没有使用过ActiveAdmin,所以也许你会在你的routes.rb上默认使用该gem。