LoginSignup
1
0

More than 5 years have passed since last update.

routes.rbにおけるresourcesの意味

Posted at

これまでGETやPOSTをそれぞれ書いていたが、resourceというものでまとめられるらしいので、そのルーティングをメモ。

resources :posts
  • get "/posts" => posts#index

  • get "/posts/new" => posts#new

  • post "/posts" => posts#create

  • get "/posts/:id" => posts#show

  • get "/posts/:id/edit" => posts#edit

  • put(patch) "/posts/:id" => posts#update

  • derete "/photos/:id" => photos#destroy

超基礎的なことだろうが、メモ。
変更があるところはresouresよりも上に書くらしい。

参考
Rails のルーティング

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