routes.rb 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #---
  2. # Excerpted from "Agile Web Development with Rails",
  3. # published by The Pragmatic Bookshelf.
  4. # Copyrights apply to this code. It may not be used to create training material,
  5. # courses, books, articles, and the like. Contact us if you are in doubt.
  6. # We make no guarantees that this code is fit for any purpose.
  7. # Visit http://www.pragmaticprogrammer.com/titles/rails4 for more book information.
  8. #---
  9. Rails.application.routes.draw do
  10. get 'admin' => 'admin#index'
  11. controller :sessions do
  12. get 'login' => :new
  13. post 'login' => :create
  14. delete 'logout' => :destroy
  15. end
  16. resources :users
  17. resources :orders
  18. resources :line_items
  19. resources :carts
  20. get 'store/index'
  21. resources :products do
  22. get :who_bought, on: :member
  23. end
  24. # The priority is based upon order of creation:
  25. # first created -> highest priority.
  26. # See how all your routes lay out with "rake routes".
  27. # You can have the root of your site routed with "root"
  28. root 'store#index', as: 'store'
  29. # ...
  30. # Example of regular route:
  31. # get 'products/:id' => 'catalog#view'
  32. # Example of named route that can be invoked with purchase_url(id: product.id)
  33. # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
  34. # Example resource route (maps HTTP verbs to controller actions automatically):
  35. # resources :products
  36. # Example resource route with options:
  37. # resources :products do
  38. # member do
  39. # get 'short'
  40. # post 'toggle'
  41. # end
  42. #
  43. # collection do
  44. # get 'sold'
  45. # end
  46. # end
  47. # Example resource route with sub-resources:
  48. # resources :products do
  49. # resources :comments, :sales
  50. # resource :seller
  51. # end
  52. # Example resource route with more complex sub-resources:
  53. # resources :products do
  54. # resources :comments
  55. # resources :sales do
  56. # get 'recent', on: :collection
  57. # end
  58. # end
  59. # Example resource route with concerns:
  60. # concern :toggleable do
  61. # post 'toggle'
  62. # end
  63. # resources :posts, concerns: :toggleable
  64. # resources :photos, concerns: :toggleable
  65. # Example resource route within a namespace:
  66. # namespace :admin do
  67. # # Directs /admin/products/* to Admin::ProductsController
  68. # # (app/controllers/admin/products_controller.rb)
  69. # resources :products
  70. # end
  71. end