Prev | Current Page 385 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


?– Note Active Record is case sensitive. This means that a field name of account_id is not the same as
a field name of Account_ID even if your database system itself does not recognize a difference. From within
your application, the attributes would be considered two different objects.
We??™ll spend a little more time on the importance of case in the next section when we
cover using the various find methods. For now though, just keep in mind that case does
matter, and since our legacy schema uses mixed case for field names, we were required to
use the set_primary_key method within each model rather than set the global attribute on
the ActiveRecord::Base class.
The other interesting thing to note about our initial setup here is that even though within
our database we store member data in the member table, within our application we defined the
model as an Account model. This means that our code will reference it as an Account object. It??™s
a subtle thing, but it should help to clear up the meaning of our model as we use it within our
code when other humans (if you can consider your developers and testers human) need to
read through our code.


Pages:
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397