Phoenix.Router.resources/4

Parsed documentation:
View on GitHub
Defines "RESTful" routes for a resource.

The given definition:

    resources "/users", UserController

will include routes to the following actions:

  * `GET /users` => `:index`
  * `GET /users/new` => `:new`
  * `POST /users` => `:create`
  * `GET /users/:id` => `:show`
  * `GET /users/:id/edit` => `:edit`
  * `PATCH /users/:id` => `:update`
  * `PUT /users/:id` => `:update`
  * `DELETE /users/:id` => `:delete`

## Options

This macro accepts a set of options:

  * `:only` - a list of actions to generate routes for, for example: `[:show, :edit]`
  * `:except` - a list of actions to exclude generated routes from, for example: `[:delete]`
  * `:param` - the name of the parameter for this resource, defaults to `"id"`
  * `:name` - the prefix for this resource. This is used for the named helper
    and as the prefix for the parameter in nested resources. The default value
    is automatically derived from the controller name, i.e. `UserController` will
    have name `"user"`
  * `:as` - configures the named helper exclusively
  * `:singleton` - defines routes for a singleton resource that is looked up by
    the client without referencing an ID. Read below for more information

## Singleton resources

When a resource needs to be looked up without referencing an ID, because
it contains only a single entry in the given context, the `:singleton`
option can be used to generate a set of routes that are specific to
such single resource:

  * `GET /user` => `:show`
  * `GET /user/new` => `:new`
  * `POST /user` => `:create`
  * `GET /user/edit` => `:edit`
  * `PATCH /user` => `:update`
  * `PUT /user` => `:update`
  * `DELETE /user` => `:delete`

Usage example:

    resources "/account", AccountController, only: [:show], singleton: true

## Nested Resources

This macro also supports passing a nested block of route definitions.
This is helpful for nesting children resources within their parents to
generate nested routes.

The given definition:

    resources "/users", UserController do
      resources "/posts", PostController
    end

will include the following routes:

    user_post_path  GET     /users/:user_id/posts           PostController :index
    user_post_path  GET     /users/:user_id/posts/:id/edit  PostController :edit
    user_post_path  GET     /users/:user_id/posts/new       PostController :new
    user_post_path  GET     /users/:user_id/posts/:id       PostController :show
    user_post_path  POST    /users/:user_id/posts           PostController :create
    user_post_path  PATCH   /users/:user_id/posts/:id       PostController :update
                    PUT     /users/:user_id/posts/:id       PostController :update
    user_post_path  DELETE  /users/:user_id/posts/:id       PostController :delete
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.