You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are not limited to the seven routes that RESTful routing creates by default. If you like, you may add additional routes that apply to the collection or individual members of the collection.
@@ -1164,15 +1166,29 @@ resources to use `photos_path` and `accounts_path`.
1164
1166
1165
1167
NOTE: The `namespace` scope will automatically add `:as` as well as `:module` and `:path` prefixes.
1166
1168
1167
-
You can prefix routes with a named parameter also:
This will provide you with URLs such as `/bob/articles/1` and will allow you to reference the `username` part of the path as `params[:username]` in controllers, helpers, and views.
1179
+
This will provide you with paths such as `/1/articles/9` and will allow you to reference the `account_id` part of the path as `params[:account_id]` in controllers, helpers, and views.
1180
+
1181
+
It will also generate path and URL helpers prefixed with `account_`, into which you can pass your objects as expected:
We are [using a constraint](#segment-constraints) to limit the scope to only match ID-like strings. You can change the constraint to suit your needs, or omit it entirely. The `:as` option is also not strictly required, but without it, Rails will raise an error when evaluating `url_for([@account, @article])` or other helpers that rely on `url_for`, such as [`form_with`][].
0 commit comments