Well I finally got off my keister and wrote up a patch for a feature a few of us have been using for a while. If you're running edge Rails, just svn up and type rake routes
to see a list of all the routes defined for your app.
If you're running an older version of Rails (1.2.3 works, not sure about pre-1.2 though) but still want in on the action, you should install sake and then pour yourself a shot:
$ sake -i http://pastie.caboo.se/74249.txt routes
$ sake routes
I've found this task indispensable when dealing with RESTful routing. If you're doing anything beyond the basics with routes, you should check this out. It can be a huge time saver.
And in closing, a little history and credit. While the patch was mine, the inspiration came from elsewhere. First there was Rick Olson's routing_navigator plugin, which I found both very useful and way too awkward to use effectively. I cobbled up some code to do that from a script, while at the same time Chris Wanstrath did the obvious thing and wrote a rake task for it. I fixed that to show routes with names. And at last I got tired of the ugly formatting and fixed it up to the current incarnation. Just goes to show that software evolution beats intelligent designers. And if a tiny little patch has even that amount of history, just think about how some of the more complicated features may have developed.
Actually, it isn't "rake rails:routes" but rather "rake routes". Nice job on getting this in to the core, I love it!
Didn't get it to work with 'rake routes' or 'rake rails:routes'. Did however work with 'sake routes' :)
Running Rails 1.2.3
Works like a charm, nice addition! Thanks
Ooh. runs a piston update Oh, wow, that's just lovely! Thank you!
Great timing! I've been looking for something like this for the past couple of weeks. Thank you!
I've seen the commit, loved it, and only 5 hours later submitted this ;)
Robert: Oh, looks like David hoisted the task up out of the rails namespace to the top level when he applied the patch. I didn't even notice! Fixed the article.
Mislav: That's pretty cool! If you want to see my other experiment, look in that same pastie for a task that dumps the routes to a HTML table with some formatting.
@Josh: David pulled a fast one. :D I used to use Rick's routing navigator all the time, but it is annoying to install, so I was really happy to see this committed to rails core!
routes2HTML, sweet :) but the HTML is much more rich, surely the output can be enhanced... accepting cool patches for this?
Mislav: I say let a thousand flowers bloom. Anyone who wants to take my little HTML experiment and do something snazzy with it has my blessing.
One thing I'd like to see added is a list of the path/url helpers - I haven't figured out how to pry them out of ActionController::Routing::Routes.named_routes.helpers nicely.
Bill: The leftmost column shows the names of the routes. Just add the _path or _url suffix to get the helper method name.
Awesome! This rocks. Thanks
Hi Josh! Thank you for your task. here is a modification with nicer output.:
http://pastie.caboo.se/96880
Bye!