โ† Ruby on Rails learning path
Ruby on Rails ยท Module 3 of 10

Models and Active Record

Active Record maps database tables to Ruby classes.

๐Ÿ“– Key ideas

  1. A Product model maps to a products table by convention.
  2. Product.create(name: "Pen", price: 10) inserts a row.
  3. Product.find(1), Product.where(price: ..100), Product.order(:name) query rows.
  4. product.update(price: 12) and product.destroy change or delete.
  5. Each row becomes an object with attribute methods.
๐Ÿ’ก Real-life example: Like a translator between Ruby and SQL: you speak Ruby, and it writes the SQL for you.
Active RecordRails ORM linking classes and tables
ORMObject-relational mapping
whereFilter rows by conditions
findFetch a row by id