Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using unnamed roots on conflict #34494

Merged
merged 1 commit into from Nov 20, 2018

Conversation

@gmcgibbon
Copy link
Member

@gmcgibbon gmcgibbon commented Nov 20, 2018

Summary

Fixes #34479.

Disallows multiple uses of root within the same routing context without as:.

The referenced issue maps the first root to /form/:foo, and a second one to /. When calling root_path in the template rendered by /, Rails knows to call the first root path (because it is the one with the name). The second root is not used, and can't be referenced by a named route helper because it doesn't have a name.

This whole situation can be avoided by not assuming a root route should be unnamed if one already exists.

r? @rafaelfranca

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Nov 20, 2018

This will need a changelog entry

Raises an ArgumentError when multiple root routes are defined in the
same context instead of assigning nil names to subsequent roots.
@gmcgibbon gmcgibbon force-pushed the warn_root_conflict branch from 82ae85b to dde9c48 Nov 20, 2018
@rafaelfranca rafaelfranca merged commit eb22adc into rails:master Nov 20, 2018
1 of 2 checks passed
@gmcgibbon gmcgibbon deleted the warn_root_conflict branch Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants