To nest routes, enclose them in do ~ end
.
config/routes.rb
resources :class_rooms, only: [:index, :new, :create, :show] do
resources :messages, only: [:index, :create, :destroy]
resources :posts, only: [:index, :new, :create]
resources :users, only: [:show, :edit, :update]
end
By nesting with do ~ end, class_rooms could be put before the URL of messages, posts, users, and ID could be included. I created it with the image of creating a hierarchy.