Prev | Current Page 25 | Next

David Berube

"Practical Reporting with Ruby and Rails"


CHAPTER 1 n DATA ACCESS FUNDAMENTALS 5
Active Record lets you define one or more models, each of which represents a single
database table. Class instances are represented by rows in the appropriate database
table. The fields of the tables, which will become your object??™s attributes, are automatically
read from the database, so unlike other ORM libraries, you won??™t need to repeat
your schema in two places or tinker with XML files to dictate the mapping. However, the
relationships between models in Active Record aren??™t automatically read from the database,
so you??™ll need to place code that represents those relationships in your models.
Creating a model in Active Record gives you quite a few features for free. You can
automatically add, delete, find, and update records using methods, and those methods
can make simple data tasks very trivial.
Let??™s look at two examples to demonstrate data manipulation with Active Record.
Calculating Player Salaries
Suppose you work for a game development company, Transmegtech Studios.


Pages:
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
Building Contractor Dexter Morgan SPA życzenia na walentynki Półpasiec