Search⌘ K

Models and Active Record

Explore how Ruby on Rails models interact with databases using the Active Record ORM framework. Learn the CRUD operations, Rails naming conventions, and how to create new models. This lesson equips you with the skills to manage data effectively in your Rails applications.

Models

Rails Model is a Ruby class that allows you to add database records in a convenient manner. Generally, you want your models to provide four basic functionalities:

  1. Create: The ability to add data to record
  2. Read: The ability to find some particular data already stored in the database
  3. Update: The ability to modify some existing data
  4. Delete: The ability to remove data

These four functionalities or operations are referred to by the acronym CRUD, which stands for create, read, update, and delete.

Rails uses the Active Record framework to facilitate the creation and use of models.


What is Active Record?

Active Record is an Object Relational Mapping (ORM) framework, which allows it to connect objects of an application to tables in a relational database management system (RDBMS).

By ...