Arun Agrawal’s Blog

Ruby on Rails Developer

Active Record

An object that wraps a row in a database table or view, encapsulate the database access, and add domain logic on that data called Active Record. Active record object carries both data and behavior. The data structure of the Active Record should exactly match that of the database: one field in the class for each column in the table. In Rails Active record comes by default as in terms of models. Active Record class contain some method which perform like :
  • Implement some pieces of business logic
  • Construct an instance of the Active Record from a SQL result set row
  • Update the database and insert into it the data in the Active Record
  • Get and set the field values
Active Record works very well when domain logic is not too complex.