0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ルーティングをネストすると…

Posted at

はじめに

 ルーティングをネストするには、do~endで囲う。

ルーティングをネストして、URLを作成する

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

do~endでネストすることで、messages,posts,usersのURLの前にclass_roomsを入れることが出来、IDを含めることができた。階層をつくっていくイメージで作成した。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?