Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lingtran/a3b0140142d7a492ba90ff21ac58f825 to your computer and use it in GitHub Desktop.
Save lingtran/a3b0140142d7a492ba90ff21ac58f825 to your computer and use it in GitHub Desktop.
Intro to Rails Routing Warm-Up Questions
  1. 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.
  1. 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
  1. 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
  1. 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
  1. 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
  1. 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
  1. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment