-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Find routes config #991
Find routes config #991
Conversation
|
||
def find_file(file_name) | ||
file = nil | ||
Find.find(Rails.root) do |path| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer detect over find.
07b9ac4
to
7fe7550
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is off to a great start!
I've left a few comments, but:
- Do you think you could look into the Hound comments?
- Do you think we need to be testing for any of the other cases which we're protecting against in this PR? I'm thinking of all of the places we branch for special cases, really.
Hi @rnice01! Sorry, it's been a while. I just answered your question left above. Do you think you'd be able to rebase against current master and fix up the remaining comments? |
@rnice01, is this a change you still want to make? |
@purinkle, yeah I can get it cleaned up. |
7fe7550
to
0f5d8ae
Compare
@@ -4,10 +4,29 @@ def call_generator(generator, *args) | |||
Rails::Generators.invoke(generator, args, generator_options) | |||
end | |||
|
|||
def find_routes_file | |||
routes_file = Rails.root.join("config/routes.rb") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails/FilePath: Please use Rails.root.join('path', 'to') instead.
0f5d8ae
to
cf109b2
Compare
Because there may be Rails projects with the routes.rb file in a different location than Rails.root/config a helper was added to locate the file. The helper will look in the 'normal' routes.rb location and then search through the project if not located there.
cf109b2
to
09ef652
Compare
PR for issue #720 : Both the Install and Routes generators were looking for the project's routes.rb file in /config from the Rail's root path. Which the helper method I added will look for first, if it cannot find the routes.rb file there, then it will search through the project until it finds the path for that file.