What is Active Record as an ORM framework in ROR?

Active Record is a part of the MVCModel View Control design pattern. Active Record serves as the Model part of the pattern used in RORRuby on Rails and works well with databases and query commands.

ORM - Object Relational Mapping provides a variety of frameworks and techniques that are helpful in working with Relational Databases such as MySQL, PostgreSQL, etc.

“Active record - an object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.” ~ M. Fowler

Active Record provides an interface and binding between the tables in a relational database and the Ruby program code that manipulates database records.

Each Active Record object has CRUD OperationsCreate, Read, Update, and Delete for database access.

Mapping in ORM

The ORM uses the data in this mappinga bridge between your objects and your tables to handle the process of translating data between database and object forms. Additionally, the ORM uses this data to construct SQL queries to insert, update, and remove data in response to changes made to those objects by the application.

In the ORM database, tables become classes, fields become attributes, and instances of the database are mapped to class objects.

Object Relation Mapping

Key points

Active Record provides several mechanisms to work with. Some interesting abilities include:

  • Representing models of the data.
  • Representing associations between models
  • Representing inheritance hierarchies through related models
  • Validating data before it is made a persistent entry in the database
  • Performing database operations in an object-oriented fashion

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved