Skip to content

Instantly share code, notes, and snippets.

@willywg
Last active April 25, 2019 15:08
Show Gist options
  • Save willywg/4ec5747546d54f42fbd74ee2cd9c131f to your computer and use it in GitHub Desktop.
Save willywg/4ec5747546d54f42fbd74ee2cd9c131f to your computer and use it in GitHub Desktop.
How create an admistrate dashboard with a moduled model
  1. If our model is Faq::UserType, then we generates the dashboard with:

rails generate administrate:dashboard faq/user_type

This generates:

Running via Spring preloader in process 21074
      create  app/dashboards/user_type_dashboard.rb
      create  app/controllers/admin/user_types_controller.rb
  1. Make the module folder inside controllers and dashboard:
mkdir app/controllers/admin/faq/
mkdir app/dashboards/faq/
  1. Move the administrate controller to module folder:
mv app/controllers/admin/user_types_controller.rb app/controllers/admin/faq/
  1. Move the dashboard to module folder:
mv app/dashboards/user_type_dashboard.rb app/dashboards/faq/
  1. Add namespace to routes:
namespace :admin do
  namespace :faq do
    resources :user_types
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment