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
Print message on stderr when no routes are defined. #9316
Conversation
|
Added all the feedback @jeremy gave me. We don't seem to have any tests on the HTML format, so I didn't write a new one... is it worth it? Also, the Any other thoughts, or should I |
|
Wouldn't it make more sense to just call |
|
@josevalim yeah, especially since this is only happening in two places. I dig it. Changing! |
|
Much cleaner, @josevalim. Good call. That's what happens when you start one place and end up another... |
| @@ -90,6 +90,12 @@ def format(formatter, filter = nil) | |||
| routes_to_display = filter_routes(filter) | |||
|
|
|||
| routes = collect_routes(routes_to_display) | |||
|
|
|||
| unless routes.any? | |||
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.
if routes.none? looks simpler for me.
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.
I always forget about none. I agree.
|
|
Print a message in both `rake routes` and at GET "/rails/info/routes" that lets you know you have no routes defined, as well as linking to the Rails Guide on the topic.
|
@fxn fixed per your comments. |
|
Looks good to me, the space before the period hurts my eyes but it is easier that I edit later, good to go! |
Print message on stderr when no routes are defined.
| For more information about routes, see the Rails Guide: http://guides.rubyonrails.org/routing.html . | ||
| MESSAGE | ||
| end | ||
|
|
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.
Y U NO USE #strip_heredoc
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.
I don't know what that is.
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.
[2] pry(main)> def hello_world
[2] pry(main)* <<-STR.strip_heredoc
[2] pry(main)* win
[2] pry(main)* STR
[2] pry(main)* end
=> nil
[3] pry(main)> hello_world
=> "win\n"
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.
FTR this was fixed in 13c9195
Newbies get confused when they run 'rake routes' and no routes are defined. Let's
point them to some documentation.
Thanks to @burtlo for the suggestion.