Rely on Rails' route
method to be correct
#1909
Merged
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.
Previously, we were searching for a
routes.rb
to verify that we'dalready added the routes or not. We don't need to do this: the
route
method will only ever inject into the
config/routes.rb
file it knowsabout — so us looking elsewhere would never make a difference to the
outcome of the generator.
On top of this, the
route
method in turn leans oninject_into_file
from Thor which is configured to not force the result.
So, much of this can go. We just continue to check that we don't
generate routes with no models.
https://github.com/rails/rails/blob/291a3d2ef29a3842d1156ada7526f4ee60dd2b59/railties/lib/rails/generators/actions.rb#L269
https://github.com/erikhuda/thor/blob/34df888d721ecaa8cf0cea97d51dc6c388002742/lib/thor/actions/inject_into_file.rb#L26