- What is the purpose of the router in a Rails project?
- The router is the "matchmaker" or "doorperson" of the Rails application.
- It looks at the HTTP verb and the URL being requested and matches it with the controller action to run accordingly. An error is provided if a match cannot be made.
- What routes would be provided to you with the line
resources :items
?
- Routes that submit to the same URL '/items' but with different HTTP verbs GET, POST, PUT, DELETE
- What does
root :to => "items#index"
represent? How would you access that route in a web app?
- landing page/URL for items as defined by the index method in the controller of the web app
- What rake task is useful when looking at routes, and what information does it give you?
- rake routes
- It outputs all the routes app knows
- How would you interpret this output:
items GET /items(.:format) items#index
- name_of_route INCOMING_HTTP_VERB /incoming_url(accepts optional file extension specification at end of route) controller_action_input_is_mapped_to
- What is one major similiarity between Rails routing + controllers and the Sinatra projects we've been building?
- Syntax to handle HTTP verbs seem to be the same
- What is one major difference between Rails routing + controllers and the Sinatra projects we've been building?
- Rails routing and controllers separate duties more than simple server built in the Sinatra projects
- What is specified in the verb block in Sinatra that may take several lines can be completed in one Rails line