Active Record connects business objects and database tables to create a persistable domain model where logic and data are presented in one wrapping.
Rails Active Record is the Object/Relational Mapping (ORM) layer supplied with Rails. It closely follows the standard ORM model, which is as follows:
tables map to classes,
rows map to objects and
columns map to object attributes
Rails Active Records provides an interface and binding between the tables in a relational database and the Ruby program code that manipulates database records. Ruby method names are automatically generated from the field names of database tables.
Each Active Record object has CRUD (Create, Read, Update, and Delete) methods for database access. This strategy allows simple designs and straightforward mappings between database tables and application objects.
Active Record‘s main contribution to the pattern is to relieve the original of two stunting problems:
- lack of associations
- lack of inheritance
By adding a simple domain language-like set of macros to describe the former and integrating the Single Table Inheritance pattern for the latter, Active Record narrows the gap of functionality between the data mapper and active record approach.
A short rundown of the major features are below, will be described in detail later- Automated mapping between classes and tables, attributes and columns.
- Associations between objects controlled by simple meta-programming macros.
- Aggregations of value objects controlled by simple meta-programming macros.
- Validation rules that can differ for new or existing objects.
- Callbacks as methods or queues on the entire lifecycle
- Observers for the entire lifecycle
- Inheritance hierarchies
No comments:
Post a Comment