Skip to content

Instantly share code, notes, and snippets.

@danjwinter
Forked from rwarbelow/week-2-diagnostic.markdown
Last active December 11, 2015 17:17
Show Gist options
  • Save danjwinter/9809bc539bee8c480b1e to your computer and use it in GitHub Desktop.
Save danjwinter/9809bc539bee8c480b1e 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 request > Domain name server process routes to appropriate server routing > Rake layer > server receives request > controller delegates and gathers appropriate status and body, using models and views where appropriate > response sent to rake layer > client receives response.

  2. Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE. GET - Read POST - Create PUT - Update DELETE - Delete

  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? 7 routes needed so that we can fake out puts and deletes since browsers don't use them and so we can render appropriate update forms.

get /something - Read get /something/new - 1/2 create - see create form post /something/new/:id 2/2 create - add to database get /something/:id 1/3 of update - see item to be updated get /something/:id/update 2/3 of update - form of current info to be altered post /something/:id/update 3/3 of update - alter database post /something/:id/delete delete :id from database

  1. Describe the function of models in the MVC structure. Perform business logic of app.

  2. Describe the function of views in the MVC structure. Provide response in a format that browser can render.

  3. Describe the function of controllers in the MVC structure. Delegate to models and views where appropriate and gather status and body to send response to requests.

  4. 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 test business logic - TrafficSpy - test .average_url_response_time method Feature tests test user stories - TrafficSpy - as a registered user, when I visit /sources/identifier, I see my app stats and page has appropriate content Controller tests test for appropriate status and bodies for given requests - TrafficSpy - when given correct params and route, a 200 status should be returned

  5. What does ActiveRecord do? Why do we use ORMs like ActiveRecord? Active record is the intermediary layer between a web frameword like rails or sinatra and a database. We use ORMs so that we can use a programming language like Ruby to talk to a database like Postgres.

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