Is there an option to make this ->
resources "users", MyApp.UserController
generate paths with parameter name other than :id
?
Use the param
parameter in the resources/4 macro:
resources "users", MyApp.UserController, param: "name"
This will generate the following routes:
Following are the additional options for resources:
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 paramter 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With