Skip to content

Instantly share code, notes, and snippets.

@martensonbj
Forked from rwarbelow/week-2-diagnostic.markdown
Last active December 11, 2015 16:49
Show Gist options
  • Save martensonbj/5d21b74196f1aa1326a5 to your computer and use it in GitHub Desktop.
Save martensonbj/5d21b74196f1aa1326a5 to your computer and use it in GitHub Desktop.
Week 2 Diagnostic
  1. Describe the request-response cycle. Start with the client making a request.
  • The client makes a request to the server using a verb and a filepath. The verb indicates what action the user wants from the server, either to create(post), read(get), update(update), or delete(delete) data in a database. The server interprets said request and returns an appropriate response. The response contains a string of information including the status of the response, what verb was sent through, and other appropriate Headers
  1. Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE

    • GET: Acts as a request for data from the server
    • POST: Acts as a request for the server to receive information and do something with it
    • PUT: Updates exisiting data in the database
    • DELETE: Deletes exisiting data
  2. What are all of the necessary routes for full CRUD functionality in Sinatra app? Why do we need seven routes when there are only four CRUD acti

    • GET /___
    • POST /___
    • GET /___/id
    • GET /___/new
    • GET /___/id/edit
    • PUT /___/id
    • DELETE/___/id
    • (Thanks to Penney for sharing her notes with me for that list). There are seven routes because in order to POST or PUT data, there are preliminary steps that are required to collect the information from the user before the data can be officially posted to the server. For example, a user has to enter their contact information before they can hit "SUBMIT" and post it to the database.
  3. Describe the function of models in the MVC structure.

  • Models hold the logic associated with a particular class in a Sinatra app. They contain the objects that are manipulated and passed onto the view.
  1. Describe the function of views in the MVC structure.
  • Views contain the code that is displayed in the browser depending on which path the user follows.
  1. Describe the function of controllers in the MVC structure.
  • Controllers take into account the path the user is following and what request is being sent to the server. They route the user to the appropriate view and pass on the necessary variables from the model.
  1. What is the difference between model tests, feature tests, and controller tests? Give an example of functionality tested using a model test, functionality tested in a feature test, and functionality tested in a controller test.
  • Model tests focus on the functionality of an individual class or table and test ruby logic -- Test that the following ruby logic collects user IDs and returns with the name of all registered users
    • Feature tests test a specific aspect of a program from the user's perspective and include a user story -- As a user, when I visit the contact page and I enter my name and I enter my email address and I click submit Then I am redirected to a thank you page that shows my data has been submitted -- Here you are testing the existence of data on said page, and functionality of any actions taken by the user
    • Controller tests test that the data from the model is interacting appropriately with the server -- Test that a post request contains all necessary data
  1. What does ActiveRecord do? Why do we use ORMs like ActiveRecord?
  • ActiveRecord is an intermediary between a user and a database language. It allows us to access and manipulate a database without having to use raw SQL, and provides additional ruby functionality to manipulate and analyze the data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment