Listing routes from controller

This may seem like a bit of an odd question, but I was wondering if
anyone could think of any cunning means of getting the equivalent of the
output of “rake routes” from within a controller. I.e., I’d like to be
able to GET a URL such as http://localhost:3000/routes and have a
summary of the available routes returned. One possible way I can see
would be to have the relevant controller make a system call to "rake
routes"and render the output as text, or to prepare such output
beforehand with a cron job and source it from a text file, but neither
option seems very elegant.

On Fri, Jan 28, 2011 at 6:39 AM, Milo T. [email protected]
wrote:

This may seem like a bit of an odd question, but I was wondering if
anyone could think of any cunning means of getting the equivalent of the
output of “rake routes” from within a controller. I.e., I’d like to be
able to GET a URL such as http://localhost:3000/routes and have a
summary of the available routes returned.

You could just incorporate the code from the rake task into a model
of your own, eh?


Hassan S. ------------------------ [email protected]
twitter: @hassan

Hassan S. wrote in post #978177:

You could just incorporate the code from the rake task into a model
of your own, eh?

Thanks - I should have thought of that…
It seems that the relevant line I was looking for is:

Rails.application.routes.routes

…which produces what is required.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs