Pavel
Pavel

Reputation: 1974

activeadmin: nested resources belongs_to

I need to make nested resources in activeadmin like

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

I tried

ActiveAdmin.register AdminDocument do

  belongs_to :company

end

But there is no result, I get an error No route matches [GET] "/admin/companies/1/admin_documents"

What am I doing wrong? Thanks!

Upvotes: 1

Views: 1699

Answers (1)

Pavel
Pavel

Reputation: 1974

All that I have need to do is

ActiveAdmin.register AdminDocument do

  controller do 
    belongs_to :company, polymorphic: true 
  end

end

routes:

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

Upvotes: 1

Related Questions