Section Introduction
This section of the course walks through how to manage data in a Rails application. This includes working with: validations, concerns, data relationships, and much more.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In this section of the course, we're going to talk about the model. Rails is an M-V-C framework, and the model represents the first part of that, which is the M. Whenever we talk about the model, we're talking about data.

The model allows us to communicate with the database and allows us to setup relationships. For example, if you have multiple tables in an application, which most applications have, then the model allows you to create the relationship between one table and another. For instance, if you have a table full of users and a table full of blog posts they've written, then you want to know which user wrote which blog post. All of that happens inside your model file.

So, we're going to talk about relationships, concerns (which is another way to manage your model code and to share code throughout the entire application), database queries, custom queries and validations. Let's dive into those demos.