| 2 | | # The priority is based upon order of creation: first created -> highest priority. |
| 3 | | |
| 4 | | # Sample of regular route: |
| 5 | | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
| 6 | | # Keep in mind you can assign values other than :controller and :action |
| 7 | | |
| 8 | | # Sample of named route: |
| 9 | | # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' |
| 10 | | # This route can be invoked with purchase_url(:id => product.id) |
| 11 | | |
| 12 | | # Sample resource route (maps HTTP verbs to controller actions automatically): |
| 13 | | # map.resources :products |
| 14 | | |
| 15 | | # Sample resource route with options: |
| 16 | | # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } |
| 17 | | |
| 18 | | # Sample resource route with sub-resources: |
| 19 | | # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller |
| 20 | | |
| 21 | | # Sample resource route within a namespace: |
| 22 | | # map.namespace :admin do |admin| |
| 23 | | # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb) |
| 24 | | # admin.resources :products |
| 25 | | # end |
| 26 | | |
| 27 | | # You can have the root of your site routed with map.root -- just remember to delete public/index.html. |
| 28 | | # map.root :controller => "welcome" |
| 29 | | |
| 30 | | # See how all your routes lay out with "rake routes" |
| 31 | | |
| 32 | | # Install the default routes as the lowest priority. |
| | 2 | map.resource :session, :collection => { :begin => :post, :complete => :get } |
| | 3 | |
| | 4 | map.with_options :controller => 'sessions' do |session| |
| | 5 | session.login 'login', :action => 'new' |
| | 6 | session.logout 'logout', :action => 'destroy' |
| | 7 | end |
| | 8 | |
| | 9 | map.resources :users |
| | 10 | map.with_options :controller => 'users' do |user| |
| | 11 | user.signup 'signup', :action => 'new' |
| | 12 | end |
| | 13 | |