これまで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よりも上に書くらしい。