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

Find routes config #991

Merged
merged 1 commit into from
Oct 6, 2020
Merged

Conversation

rnice01
Copy link
Contributor

@rnice01 rnice01 commented Sep 30, 2017

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.

lib/administrate/generator_helpers.rb Outdated Show resolved Hide resolved

def find_file(file_name)
file = nil
Find.find(Rails.root) do |path|

Choose a reason for hiding this comment

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

Prefer detect over find.

lib/administrate/generator_helpers.rb Outdated Show resolved Hide resolved
lib/administrate/generator_helpers.rb Outdated Show resolved Hide resolved
@rnice01 rnice01 force-pushed the find-routes-config branch 3 times, most recently from 07b9ac4 to 7fe7550 Compare October 7, 2017 15:03
Copy link
Member

@nickcharlton nickcharlton left a 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.

spec/lib/administrate/generator_helpers_spec.rb Outdated Show resolved Hide resolved
lib/administrate/generator_helpers.rb Outdated Show resolved Hide resolved
lib/administrate/generator_helpers.rb Outdated Show resolved Hide resolved
lib/administrate/generator_helpers.rb Show resolved Hide resolved
@nickcharlton
Copy link
Member

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?

@purinkle
Copy link
Contributor

@rnice01, is this a change you still want to make?

@rnice01
Copy link
Contributor Author

rnice01 commented Jul 20, 2019

@purinkle, yeah I can get it cleaned up.

@nickcharlton nickcharlton added the maintenance to keep up with changes around us label Jan 2, 2020
lib/administrate/generator_helpers.rb Show resolved Hide resolved
@@ -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")
Copy link

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.

@nickcharlton nickcharlton added feature new functionality that’s not yet implemented install initial setup, first-run experience, generators and removed maintenance to keep up with changes around us labels Oct 6, 2020
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.
@nickcharlton nickcharlton merged commit 3a7e887 into thoughtbot:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new functionality that’s not yet implemented install initial setup, first-run experience, generators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants