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

Scope generated route helpers to an instance of RoutesProxy #46974

Merged
merged 1 commit into from Jan 12, 2023

Conversation

f-mer
Copy link
Contributor

@f-mer f-mer commented Jan 12, 2023

Motivation / Background

This Pull Request has been created because RoutesProxy caches route helpers within its class using self.class.class_eval(...). For example if two engine Weblog::Engine and Metrics::Engine are mounted within your app and only weblog defines the route helper weblogs_path calling metrics.respond_to?(:weblogs_path) will return true if previously weblog.weblogs_path has been called.

Detail

This Pull Request changes self.class.class_eval(...) to instance_eval(...) so route helpers are cached within the instanced object instead of the class so they are not shared by all instances.

Additional information

I would love to get feedback if there is a better way to test this.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

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

Successfully merging this pull request may close these issues.

None yet

2 participants