I'm new to rails (building my first app) and right now my .rb routes are pretty messy. I was wondering what is the best way to organize / format all the content, so itβs easy to see what happens and avoid stupid routing errors.
Any general tips or simplified examples would be appreciated.
routes.rb
Rails.application.routes.draw do resources :posts get 'users/index' #devise_for :admins namespace :super_admin do #superadmin stuff resources :dashboard, only: [:index] end devise_for :super_admins, path: "super_admin", controllers: { registrations: "registrations", sessions: "super_admin/sessions" } #lets super admin sign in get 'welcome/index' root to: "welcome#index" match '/teachers', to: 'teachers#index', via: 'get' #route to delete users match 'users/:id' => 'users#destroy', :via => :delete, :as => :admin_destroy_user match '/users/:id', to: 'users#show', via: 'get' #routes for registration devise_for :users, controllers: { registrations: "registrations" } devise_for :teachers, controllers: { registrations: "teacher/registrations" } get 'users/:id/posts' => 'users#posts', :as => :user_posts match '/users', to: 'users#index', via: 'get' match '/about', to: 'about#index', via: 'get' match '/teachers/:id', to: 'teachers#show', via: 'get' match '/teachers/list', to: 'teachers#list', via: 'get' get 'super_admin/dashboard/new_user', :as => :super_admin_new_user resources :users, :only =>[:show]
source share