articles, what is the correct URL path and HTTP method to access the edit action for the article with ID 5?The edit action in RESTful routes uses the GET method and the URL pattern /resource/:id/edit. For articles with ID 5, it is GET /articles/5/edit.
products resource?The resources :products declaration creates all seven RESTful routes (index, show, new, create, edit, update, destroy) for multiple products. resource (singular) is for a single resource without index.
resources :comments, what controller action and params hash will be called when a DELETE request is sent to /comments/42?DELETE /comments/42 calls the destroy action in CommentsController with params[:id] = '42'. The param key is always id for RESTful routes.
routes.rb:
resources :users get '/users/new', to: 'users#show'What problem will this cause when accessing
/users/new?The custom route get '/users/new' matches before the RESTful new route, so it calls users#show instead of users#new. This breaks the expected behavior for the 'new' page.
resources :authors do resources :books endWhat is the URL and params hash for accessing the 'show' action of book with ID 7 belonging to author with ID 3?
Nested RESTful routes include the parent resource ID in the URL and params. For authors/3/books/7, params[:author_id] is '3' and params[:id] is '7'.