Ensure routes are loaded, prior to generating them #148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some gems and initializers attempt to generate javascript, which can include the routes file, prior to routes be initialized. This addition provides insurance against that.
Notably: This gem will not work with the react-rails gem, due to what happens in the call on this line: https://github.com/reactjs/react-rails/blob/1c03b00b8105c78fbf674abe34be4941084bede4/lib/react/rails/railtie.rb#L62
Manifests, which may include js-routes will be rendered prior to routes being loaded, resulting in an empty set of routes being generated.
This is not, however, the only case where this bug can occur. It happens any time routes are accessed inside an initializer, or in a rails app's
after_initialize
hook.