Routing in Rails 3

Root Route

root :to => 'welcome#show'.

Named Route

match ‘logout’, :to => ‘sessions#destroy’

RESTful Routes

resources :products

Nested Resources

resources :projects do

resources :tasks, :people

end

Namespaced Resources

namespace :admin do

resources :projects

end

Some example :

  match "/about(.:format)" => "info#about", :as => :about

  match "/:year(/:month(/:day))" => "info#about", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ }
Advertisements