Skip to content

Instantly share code, notes, and snippets.

@cassiomarques
Created May 28, 2012 13:25
Show Gist options
  • Save cassiomarques/2819167 to your computer and use it in GitHub Desktop.
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 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
@cassiomarques
Copy link
Author

@tinogomes,

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!

@lucascaton
Copy link

Nice :-)

@pahnin
Copy link

pahnin commented Sep 17, 2013

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment