ORM - Object-Relational Mapping - and

Object-Relational Mapping is when an object oriented programming language has to be turned into a scalar language.  Scalar means that variables can only hold one type of value, as in C or SQL. For example, a MySQL table can only hold strings, integer, etc.  Whereas a Ruby object / variable can have many attributes, and does not need to be only a string object, or only an integer.  

An ORM layer maps tables to classes, rows to objects, and columns to attributes of those objects.  ActiveRecord is the ORM layer supplied with Rails.

ActiveRecord relieves us of the hassle of talking in SQL or PostGres to a database.  Instead we can just use Rails / Ruby:

order = Order.find(1)

order.pay_type = „Purchase Order“



| Back