el_quick el_quick - 7 months ago 22
Ruby Question

how get all routes in my rails application?

can I get all routes in my rails application? I need an output like

rake routes
and put the result in an array.

Is it possible? how?

Answer

You could have a look at way rails spits out those routes from the rake task. It's in /gems/rails/2.3.x/lib/tasks/routes.rake for Rails 2. Seems to be basically doing ActionController::Routing::Routes.routes in the general case and then interrogating that.