Koskamo

Active Record basics and conventions

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Active Record, the M in MVC, wraps database rows to store and retrieve Ruby object attributes without direct SQL, minimizing database access code. Use it to represent models, associations, inheritance, and validations. Adhere to Rails conventions to avoid explicit configuration; this includes pluralizing model class names for database tables, such as Book to books, and converting multi-word UpperCamelCase classes to snake_case tables like BookClub to book_clubs. By default, Active Record assigns an integer id as the primary key, using bigint for PostgreSQL, MySQL, and MariaDB. Basic knowledge of relational database management systems and SQL enhances understanding. These practices ensure objects map closely to underlying record structures, enabling easy reading and writing to persistent storage while supporting domain logic within the model layer. Scope: Rails. Reviewed October 4, 2026.

Source and provenance

Original source
guides.rubyonrails.org
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.