0
1

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 5 years have passed since last update.

[route] resourcesで書くとpathやURIは何になる??

Last updated at Posted at 2019-11-13

便利なresourcesだけどpath名やURI忘れちゃうのでメモ。
Rails 5.1.7 です。

resourcesを単数で使うとき

例えば

resource :profile

とするとpathやURIは以下の通り。

 2019-11-14 1.03.05.png

resourcesを複数で使うとき

resources :users

と複数形にするとpathやURIは以下の通り。

 2019-11-14 0.51.02.png

resourcesをネストして使うとき

resources :users do
  resources:posts
end

とするとpathやURIは以下の通り。

 2019-11-14 0.48.42.png

以上です!間違っていたらぜひ教えていただけると嬉しいです!
resouces以外にもscopeなどの書き方もあるので、状況に合ったものを使えるようになりたいです!

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?