Created
May 28, 2012 13:25
-
-
Save cassiomarques/2819167 to your computer and use it in GitHub Desktop.
Display your routes right at Rails Console, instead of waiting for rake to load your app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is part of my .pryrc. | |
# I put this at the section where I load Rails stuff, so I can use Pry instead of IRB | |
# for my Rails Console sessions | |
# Once this is loaded, just run the display_routes method from the console to see the same output that rake routes displays. | |
# I think it's better because I always leave a Rails console session running :) | |
require 'rails/application/route_inspector' | |
def display_routes | |
Rails.application.reload_routes! | |
routes = Rails.application.routes.routes | |
inspector = Rails::Application::RouteInspector.new | |
puts inspector.format(routes, ENV['CONTROLLER']).join "\n" | |
end |
I haven't thought about that! Cool! Now, to see which one is better we would need to do some benchmarking... But I think that running it as a rake task will load more stuff. What do you think?
Thanks!
Nice :-)
👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not?