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

Add config.include_application_routes to allow skipping inclusion of application routes #1906

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

elia
Copy link
Collaborator

@elia elia commented Nov 9, 2023

What are you trying to accomplish?

Work with components for Rails engines that provide route helpers that should stay separated from the main app routes.

What approach did you choose and why?

Instead of trying to automatically detect and include the engine's routes seems better to just opt out of application routes and manually include MyGem::Engine.routes.url_helpers.

Anything you want to highlight for special attention from reviewers?

Would be even better to opt out of application routes individually for children of ViewComponent::Base so that the engine components can have their base class while ApplicationComponent still gets the app routes by default.

…f application routes

This comes in handy when using components from within engine that shouldn't access
application routes and can opt for including engine routes instead.
@joelhawksley
Copy link
Member

@elia do you still think this change is a good idea?

@elia
Copy link
Collaborator Author

elia commented Aug 28, 2024

@joelhawksley absolutely, will give much more freedom when it comes to using VC within engines.

@joelhawksley
Copy link
Member

@elia cool! I'm wondering if there are any other options besides blanket disabling of routes. Can you think of another approach?

@elia
Copy link
Collaborator Author

elia commented Aug 29, 2024

@joelhawksley in this case rather than disabling all the routes just puts them behind their "mounted_helpers" so the main app routes are still reachable via main_app.posts_path. This allows engines to put their routes as the default or to stick to explicit naming (my_comments_engine.comments_path).

Would you prefer a solution always having a set of routes included? Be it the engine's or the main app's?

@joelhawksley
Copy link
Member

Would you prefer a solution always having a set of routes included? Be it the engine's or the main app's?

My preference is to avoid a breaking change. What do you think?

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.

2 participants