Created
December 14, 2011 12:37
-
-
Save mattsoutherden/1476415 to your computer and use it in GitHub Desktop.
Rails 3 Routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 2 routing | |
# | |
map.resource :city, :as => ":city" do |city| | |
city.login 'login', :controller => 'cities', :action => 'login' | |
city.resources :orders, :only => [ :show, :update ] | |
end | |
# city_login /:city/login {:controller=>"cities", :action=>"login"} | |
# | |
# city_order GET /:city/orders/:id(.:format) {:controller=>"orders", :action=>"show"} | |
# PUT /:city/orders/:id(.:format) {:controller=>"orders", :action=>"update"} | |
# Rails 3 Routes | |
# | |
resource :cities, :as => 'city', :path => ":city" do | |
match 'login' => 'cities#login' | |
resources :orders, :only => [ :show, :update ] | |
end | |
# login_city /:city/login(.:format) {:action=>"login", :controller=>"cities"} | |
# | |
# city_order GET /:city/orders/:id(.:format) {:action=>"show", :controller=>"orders"} | |
# PUT /:city/orders/:id(.:format) {:action=>"update", :controller=>"orders"} | |
Note that in Rails 2 the login route helper is city_login_path(), whereas Rails 3 the | |
generated helper is login_city_path(). But the nested order routes are both city_order_path() | |
Is there a way to make the single 'match' route consistent with the resources in Rails 3? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment