We??™ve merely supplied the database
connection parameters.
Finally, we instantiate a new Account object, set the username member variable, and save
the instance of the object back to the database.
It??™s possible to merely connect to the database and be up and running because of the
assumptions that Active Record is making and because Active Record gets the rest of its configuration
from the database itself.
Active Record Assumptions and Conventions
Our first Active Record program example makes full use of Active Record assumptions and coding
conventions. This speeds our development, eases our typing workload, and makes our example
seem almost magical. Active Record makes the following assumptions:
??? It infers database table names based on class names.
??? It assumes the existence of certain database columns.
The first assumption of an Active Record class is the table name. In the case of our Account
class, the table Active Record assumes is accounts. It makes this assumption based on the following
guidelines:
??? The name of the table within the database is the pluralized name of the class defined in
your Active Record program.
Pages:
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89