-
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.
-
Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE. GET - Read POST - Create PUT - Update DELETE - Delete
-
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
-
Describe the function of models in the MVC structure. Perform business logic of app.
-
Describe the function of views in the MVC structure. Provide response in a format that browser can render.
-
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.
-
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
-
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.