public
Created

Rails 2.3.2 Routing Example

  • Download Gist
rails-2.3.2-example.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
#config/routes.rb
map.route_a 'my_controller', :controller => "Users", :action => "a"
map.route_b 'my_controller/uid/:uid', :controller => "Users", :action => "b"
 
#Generated Links
route_a_url() ---> http://localhost:3000/my_controller
route_b_url(:uid => 10) ---> http://localhost:3000/my_controller/uid/10
#Requesting to the above url redirects two different actions
 
#Output of rake routes
route_a /my_controller {:controller=>"Users", :action=>"a"}
route_b /my_controller/uid/:uid {:controller=>"Users", :action=>"b"}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.