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

Allow applications to declare their own root routes #1013

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

jagthedrummer
Copy link
Contributor

Previously if you tried to declare a public root route (without a unique as: reference) you'd get an ArgumentError saying:

Invalid route name, already in use: 'root'

Similary if you tried to declare an account scoped dashboard route (with an as: 'dashboard' reference) you'd get an ArgumentError saying:

Invalid route name, already in use: 'account_dashboard'

Both of these errors were happening when we tried to draw default routes after the application had already declared them.

Now we resuce the ArgumentError and check the message to see if it's a complaint about a duplicate route. If so, we do nothing and let the app use the route defined in the primary config/routes.rb file.

Fixes bullet-train-co/bullet_train#1656

Previously if you tried to declare a public root route (without a unique
`as:` reference) you'd get an `ArgumentError` saying:

```
Invalid route name, already in use: 'root'
```

Similary if you tried to declare an account scoped dashboard route (with
an `as: 'dashboard'` reference) you'd get an `ArgumentError` saying:

```
Invalid route name, already in use: 'account_dashboard'
```

Both of these errors were happening when we tried to draw default routes
after the application had already declared them.

Now we resuce the `ArgumentError` and check the message to see if it's a
complaint about a duplicate route. If so, we do nothing and let the app
use the route defined in the primary `config/routes.rb` file.

Fixes bullet-train-co/bullet_train#1656
jagthedrummer added a commit to bullet-train-co/bullet_train that referenced this pull request Jan 29, 2025
@jagthedrummer jagthedrummer merged commit effc3b3 into main Jan 29, 2025
36 checks passed
@jagthedrummer jagthedrummer deleted the jeremy/application-root-routes branch January 29, 2025 19:51
jagthedrummer added a commit to bullet-train-co/bullet_train that referenced this pull request Jan 29, 2025
* Document the fact that apps can declare their own root routes

Joint PR: bullet-train-co/bullet_train-core#1013

* linter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Root route should be configurable
1 participant