resources :posts tự động tạo 7 route RESTful chuẩn:
| HTTP Verb | Path | Action | Helper |
|---|---|---|---|
| GET | /posts | index | posts_path |
| GET | /posts/new | new | new_post_path |
| POST | /posts | create | posts_path |
| GET | /posts/:id | show | post_path(id) |
| GET | /posts/:id/edit | edit | edit_post_path(id) |
| PATCH/PUT | /posts/:id | update | post_path(id) |
| DELETE | /posts/:id | destroy | post_path(id) |
Dùng only: / except: để giới hạn: resources :comments, only: [:index, :create, :destroy].
resources :posts automatically generates 7 standard RESTful routes:
| HTTP Verb | Path | Action | Helper |
|---|---|---|---|
| GET | /posts | index | posts_path |
| GET | /posts/new | new | new_post_path |
| POST | /posts | create | posts_path |
| GET | /posts/:id | show | post_path(id) |
| GET | /posts/:id/edit | edit | edit_post_path(id) |
| PATCH/PUT | /posts/:id | update | post_path(id) |
| DELETE | /posts/:id | destroy | post_path(id) |
Use only: / except: to restrict: resources :comments, only: [:index, :create, :destroy].