Skip to content

Instantly share code, notes, and snippets.

@matt-stj
Forked from rwarbelow/week-2-diagnostic.markdown
Last active October 26, 2015 17:59
Show Gist options
  • Save matt-stj/9cf14aa5467284ec7576 to your computer and use it in GitHub Desktop.
Save matt-stj/9cf14aa5467284ec7576 to your computer and use it in GitHub Desktop.
1. Describe the request-response cycle (start with the client making a request).
* The client sends a request to the server with a verb (GET) and a path (/tasks) that it wants to ineract with.
* The server/router accepts that request and sends it to the controller.
* The controller routes the request to the proper location with the proper action (get, post, etc.)
* If the request requires pulling informaiton out of the database then the controller passes the request to the models, which then fetches from the database and hands it back to the controller.
* The controller then passes the available information over to the views, and the views build a page with the requested info.
* The views send the page back to the controller, where it renders HTML that gets sent back to the server.
* The server then sends a response to the client with information about whether the request was successful or not -- and if so, it passes the html in though the response body.
2. Explain the use of each of these HTTP verbs: GET, POST, PUT, DELETE.
GET - will retrieve information from the server
POST - will send information to the server, to be stored for later.
PUT - will update something that was already POSTed
DELETE - the oppoite of POST - destroys the record.
3. What routes are necessary for full CRUD functionality in an app like SkillInventory or RobotWorld? Explain the purpose of each route.
get '/index' - show all robots (read)
get '/robots/new' - pull up a page that will allow the user to input details to build a new robot.
post '/robots/new' - send robot data to the server for the app to save. (create)
get '/robots/id' - view details associated with a particular robot.
get 'robots/edit' - pull up a form for the user to edit a robot.
put '/robots/edit' - request that the existing robot's data be updated. (update)
delete '/robots/id' - remove the robot from the database (delete)
4. Describe the functions of models, views, and controllers in the MVC structure.
Model - Handles all interactions with objects/databses.
View - provides a template for us to render our pages for the user.
Controller - handles incoming and outgoing requests and routes them to the correct place -- ensuring that they have access to the correct data that they need.
5. What is the difference between model tests, feature tests, and controller tests?
Model Tests - Ensures that our classes and objects are working the way that we'd expect them to.
Feature Tests - mimics a user interaction with a page. Using capybara, we can write tests that replicate how a real user would interact with our views, and ensure that the proper information is displayed to them.
Controller Tests - ensures that our app is sending and receiving the right info.
6. Why do we use ORMs like ActiveRecord?
Bridge between DB and APP. Allows us to write ruby code to query a SQL DB (translator).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment