Models and Active Record
A brief introduction to Rails models and Active Record conventions
We'll cover the following
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:
- Create: The ability to add data to record
- Read: The ability to find some particular data already stored in the database
- Update: The ability to modify some existing data
- 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 making use of ORM, Active Record bypasses the need for writing SQL statements directly, allowing easier storage and retrieval of properties and relationships of the objects in your application.
Get hands-on with 1200+ tech skills courses.