# Route Information

**URL:** <https://www.ruby-forum.com/t/route-information/120427>\
**Category:** Rails\
**Created:** [November 16, 2007, 9:21pm UTC](https://www.ruby-forum.com/t/route-information/120427 "2007-11-16T21:21:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 16, 2007, 9:21pm UTC](https://www.ruby-forum.com/t/route-information/120427/1 "2007-11-16T21:21:55Z")

</div>

Is there a method to return a hash of the route configuration based on  
a path?

For example:

magic\_method(’/my\_controller/my\_action/my\_id’)  
=\>  
{:controller =\> ‘my\_controller’, :action =\> ‘my\_action’, :id =\>  
‘my\_id’}

Thanks!  
Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 16, 2007, 11:26pm UTC](https://www.ruby-forum.com/t/route-information/120427/2 "2007-11-16T23:26:36Z")

</div>

On Nov 16, 2007, at 12:21 PM, TomRossi7 wrote:

> Is there a method to return a hash of the route configuration based on  
> a path?
> 
> For example:
> 
> magic\_method(’/my\_controller/my\_action/my\_id’)  
> =\>  
> {:controller =\> ‘my\_controller’, :action =\> ‘my\_action’, :id =\>  
> ‘my\_id’}

recognize\_path(’/my\_controller/my\_action/my\_id’)

– gw (www.railsdev.ws)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 17, 2007, 2:23am UTC](https://www.ruby-forum.com/t/route-information/120427/3 "2007-11-17T02:23:47Z")

</div>

Excellent! That is exactly what I am looking for except I can’t seem to  
figure out how to call the method.  
From an IRB console:

> > ActionController::Routing::RouteSet.recognize\_path  
> > (’/my\_controller/my\_action/my\_id’)  
> > NoMethodError: undefined method `recognize\_path’ for  
> > ActionController::Routing::RouteSet:Class

I am running Rails 1.2.5 if that matters.

Thanks!  
Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 17, 2007, 3:22pm UTC](https://www.ruby-forum.com/t/route-information/120427/4 "2007-11-17T15:22:52Z")

</div>

Hi –

On Fri, 16 Nov 2007, Tom R. wrote:

> Excellent! That is exactly what I am looking for except I can’t seem to  
> figure out how to call the method.
> 
> > From an IRB console:
> 
> > > ActionController::Routing::RouteSet.recognize\_path  
> > > (‘/my\_controller/my\_action/my\_id’)  
> > > NoMethodError: undefined method `recognize\_path’ for  
> > > ActionController::Routing::RouteSet:Class

ActionController::Routing::Routes.recognize\_path

David

–  
Upcoming training by David A. Black/Ruby Power and Light, LLC:

- Advancing With Rails, Berlin, Germany, November 19-22
- Intro to Rails, London, UK, December 3-6 (by Skills Matter)  
See [http://www.rubypal.com](http://www.rubypal.com) for details!
