Thu Sep 06 12:39:00 UTC 2007

testing your restful routes

Posted in Rails at 12:39 PM by matt

script/console
>> irb ActionController::Routing::Routes
rs = ActionController::Routing::Routes
rs.named_routes.each {|name, route| puts( name, route) }; 1
Just copy the list of helper methods show in the output of step 4 and append path to that name. You must also provide the required ids shown in the output. For example take the output:

user GET /users/:id/ {:action=>”show”, :controller=>”users”}

and in the console, type:
>> user_path 1
=> "/users/1" 
The same process can be used for nested routes.

Reference: Rails Routing by David A Black. This book gave me a solid understanding of routes.

-taken from blog spot

Leave a Comment