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

Rely on Rails' route method to be correct #1909

Merged
merged 1 commit into from
Feb 16, 2021
Merged

Conversation

nickcharlton
Copy link
Member

@nickcharlton nickcharlton commented Feb 15, 2021

Previously, we were searching for a routes.rb to verify that we'd
already 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 knows
about — 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 on inject_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

Copy link
Contributor

@cernivec cernivec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Previously, we were searching for a `routes.rb` to verify that we'd
already 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 knows
about — 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 on `inject_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
@nickcharlton nickcharlton changed the title Fix a bug where we can't generate routes on complex applications Rely on Rails' route method to be correct Feb 16, 2021
@nickcharlton nickcharlton merged commit 9685606 into master Feb 16, 2021
@nickcharlton nickcharlton deleted the nc-always-route branch February 16, 2021 10:16
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