Dorian Dorian - 1 year ago 74
Ruby Question

Result of `rake routes` in ruby script

rake routes
is very slow (30s in my computer) but I need it for routing spec.

So, is there a way to get all routes like rake routes? (or how rake routes works?)

I use Rails 3 and all I have seen is for Rails 3, and I found nothing I can use in the rails doc.

Answer Source


.to_a is optional, it just converts it to an array.

(I found this line in railties/lib/rails/tasks/routes.rake)

I use it like : routes[10].defaults => {:action=>"edit", :controller=>"polls"}

Edit : You can find the (quite hacky) way I do my routing specs here :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download