Though this material was first introduced in week 5, we're putting it somewhere in the middle between week 5 and 6 since modeling took up most of our attention

Learning Goals 🎯

  1. Understand the different types of requests and what data operations they're tied to
  2. Acknowledge some of the assumptions and assertions that Rails makes on our code.
  3. Be able to follow Rails' convention for route naming and utilize Rails' generators to help you

Prerequisites 🤔

So far in this class, we have discussed most of the big foundational concepts of Ruby on Rails. We've talked about how the web uses requests to communicate and how it's the job of a webserver written using a framework like Rails to recieve and respond to these requests. We've also talked about how Rails maps a request to an action in the controller. We've used Embedded Ruby (ERB) files to render our view programmatically. And we've discussed how we can keep data around in a database and how Rails provides an easy way to do that. Whew, that's a lot!

Through these integral concepts, we've been presented with building blocks. With these blocks, we can feasibly accomplish anything! But it's still kinda daunting. Think how many routes an app like facebook has! Do I have to write all of those in one long file if I want an app that successful? There's so many ways to label your routes, how do we keep it all consistent? These are totally valid and fantastic questions! In Homework 2, we built an application that utilized all these features, but it was a little messy and disorganized. Our create and new routes had different url's but our update routes shared one.

There's so many choices to make, and it's hard to start from nothing. The creator of Rails, in turn, believed in a magical principle called "Convention over Configuration"

In this guide, you're going to learn how to use those building blocks from the first few weeks of the semester to make beautiful buildings using this principle. We're going to talk about some more conventions of the web that relate to the models we introduced last week, and we're going to talk about how Rails helps us be more consistent by imposing it's opinion on how things should be structured.

The Various Types of Requests

We introduced the concept of requests by covering two different types: GET requests and POST requests. At a basic level, GET requests ask for data while POST requests usually send data. This is a perfectly cursory overview, but in the context of a webserver, there's a few more important types of requests.