activeadmin:嵌套资源belongs_to

时间:2014-09-02 21:02:24

标签: ruby-on-rails ruby-on-rails-4 activeadmin

我需要在activeadmin中创建嵌套资源,如

http://localhost:3000/admin/companies/1/admin_documents

我试过

ActiveAdmin.register AdminDocument do

  belongs_to :company

end

但是没有结果,我收到错误No route matches [GET] "/admin/companies/1/admin_documents"

我做错了什么?谢谢!

1 个答案:

答案 0 :(得分:1)

我需要做的就是

ActiveAdmin.register AdminDocument do

  controller do 
    belongs_to :company, polymorphic: true 
  end

end

路线:

namespace :admin do
  resources :companies do
    resources :admin_documents
  end
end