Friday, April 12, 2013

[Rails] How to iterate over an application route set?

Hi,

I would like to be able to iterate over all my application routes. Basically, like "rake routes" does. My goal is:
- to generate code from that routes set
- pretty print each route spec
- build a complete mapping between the controllers' actions and the routes.

I have found some interesting classes in rails source code, but they look like I should not use them because they are for internal use only. Something like:

$ rails c
Rails.application.routes.named_routes.each {|n, r| p '==============', n, r }

or this class ActionDispatch::Routing::RoutesInspector

Is there a public API that would be maintain across different rails releases that I could use?

Thanks in advance,

--
Nicolas Desprès

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate