parm530
6/28/2018 - 2:22 PM

Routes

Changes in route definition

RESTful Routes

  • Use resources :model_name_plural
  • This will generate all the REST-ful routes for that resource EXCEPT delete
    • You will need to add:
    #config/routes
    resources :subjects do
      member do 
        get :delete
      end
    end
    #provides all 8 RESTful actions!!
    
    • Otherwise, you will need JS to ask the user to delete the resource! ("Are you sure?")
  • member routes
    • Operate on a single record of the resource, so it will expect you to provide the :id for the route
    • Examples of this kind of route include edit and show
  • collection routes
    • No need to pass in the :id of a record!
    • index is an obvious collection route
    • Also, new & create, even though they might not appear to be (they don't operate on a single member)