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 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.