Skip to content

Instantly share code, notes, and snippets.

@bethsebian
Forked from rwarbelow/week-2-diagnostic.markdown
Last active December 11, 2015 16:49
Show Gist options
  • Save bethsebian/61563198901ac949d82f to your computer and use it in GitHub Desktop.
Save bethsebian/61563198901ac949d82f 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.
- Client sends a request to a server, request contains verb, path, header, body
- Server directs the request to the controller
- Controller delegates relevant info from the request to models, and then defines a view, status, and message (optional).
- Controller passes info to server
- Server bundles that information (with header, body) and sends to the user's browser
- User's browser updates the presentation of information within their browser window. If the request was successful, the view will be implemented, if the view is not successful, and error message will appear if one's been defined.

2. Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE.
- GET: Retrieve information from the server, can include data from database
- POST: Make some change through server, can include creating data in the database
- PUT: Make a change to existing data in database
- DELETE: Remove data from database

**3. 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 actions? **
Without using resources
- GET /index
-
- GET id/add
- POST id
- GET id/edit
- PUT id
- DELETE id

With using resources
- READ /index
- READ /index/id
- CREATE /index/new
- CREATE /index
- UPDATE /index/id/edit
- UPDATE /index/id
- DELETE /index/id

4. Describe the function of models in the MVC structure.
Models manage input and other functions stemming from one data table within a database Models hold model methods, which should capture and organize data built around the given model's object Models manage the criteria for adding data into its corresponding table.

5. Describe the function of views in the MVC structure.
Views hold HTML to create user interfaces for viewing summaries of data in the database.

6. Describe the function of controllers in the MVC structure.
Controllers take input from the client, delegate that input to appropriate models, and return a view, status, and optional response to the user.

7. 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 address the relationship between one tables data and other related tables. They also test methods to describe and summarize data stemming from the model. Feature tests address whether views present the user with the desired information and options. Controller tests address whether a client request produces the overall desired status, message, and views.

8. What does ActiveRecord do? Why do we use ORMs like ActiveRecord?
ActiveRecord serves as a liaison between a database user and a database. It provides the database user defined methods for querying and summarizing data. For example, ActiveRecord provides methods and rubric for adding and formatting data in the database, editing and deleting data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment