Routing issue with rails

I have following routes:
map.resources :users

ruby script/console

rs = ActionController::Routing::Routes
rs.recognize_path(’/users/2’)
=> {:controller=>“users”, :action=>“2”}

The output is not correct.

However if I user helper, I get correct answer.

helper.users_path
=> “/users”

How do I play with REST routes in console?

You can look on a cheatsheet to see what to expect:

On Tue, May 20, 2008 at 7:30 AM, Raj S.
[email protected]
wrote:


Appreciated my help?
Reccommend me on Working With Rails
http://workingwithrails.com/person/11030-ryan-bigg

You don’t really need console to see the routes.
You can create a new empty project and change the routes.rb without
adding anything else (no appropriate controllers, models, views, no
anything) and Rake routes will still list the routes that your
routes.rb would create. It is a fast way to check your routing.

Good luck

I know rake routes prints all the routes. However I wanted to know why
the routing was not working with rs.

However I found the answer.

Instead of

rs.recognize_path(’/users/2’)

I need to use

rs.recognize_path(’/users/2’,:method => :get)

for a resource.