ActiveRecord

Basics

ORM in Rails

Object

+

Relational 

Mapping

ORM

ActiveRecord connects classes to relational database tables.

'M' in MVC

Model

The layer of the system responsible for representing business data and logic.

Associations

Associations

  • belongs_to
  • has_one
  • has_many
  • has_many :through
  • has_one :through
  • has_and_belongs_to_many

Validations

Active Record Pattern

"An object that wraps a row in a database table or view,
encapsulates the database access, and adds domain logic on that data."

         - Martin Fowler 

Write code

Thanks

ActiveRecord Basics

By Rajeev Bharshetty

ActiveRecord Basics

  • 1,377