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.
You could just incorporate the code from the rake task into a model of your own, eh?
Hassan Schroeder 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.