Prev | Current Page 458 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

For more
information about this plug-in, visit http://mir.aculo.us/2005/10/30/localization-plugin.
CHAPTER 8 ?–  ACTIVE RECORD AND THE REAL WORLD 204
How Do I Use Composite Primary Keys?
Because Active Record is opinionated software, it includes no support for using composite primary
keys. Even if, like the Active Record developers, you believe that composite primary keys are
generally unnecessary, many legacy database schemas may use composite primary keys.
Fortunately, there is an Active Record extension that adds composite primary key support. You
can download and find documentation on this plug-in at http://compositekeys.rubyforge.org.
How Do I Use GUID/UUID Primary Keys?
Active Record not only uses sequential, integer primary keys by default, but contains no builtin
support for any other type of primary key. Fortunately, it is relatively straightforward to
override the default primary key behavior of Active Record to use nonsequential, noninteger
primary keys.
There are actually two different methods of overriding Active Record to support Universally
Unique Identifier (UUID) primary keys: including the UUID functionality in a module
and using an abstract Base class.


Pages:
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470