rails_admin add custom controller in namespace admin

1k views Asked by At

I'm heaving a problem - in my app i'm using rails_admin and want to add a custom controller to 'admin' namespace.

i create a custom controller Admin::CustomController Then i create a link to it in rails_admin.config

  config.navigation_static_links = {
      'Custom Controller' => '/admin/custom'
  }

i get a warning when i try to access this link via browser

Model 'Custom' could not be found  

How can fix this issue ?

1

There are 1 answers

0
dalpo On

To fix the problem relative to the Model 'Custom' could not be found, you have to create a routes for your custom controller and define it before the rails_admin routes mount point.

For instance in your routes.rb:

# must be before rails_admin
namespace :admin do
  resource :custom
end

mount RailsAdmin::Engine => '/admin', as: 'rails_admin'