??”Alan Kay
Ruby on Rails was designed as a loosely coupled set of components (ActionPack,
ActiveRecord, ActiveResource, ActiveSupport, and ActionMailer) with some glue to
hold them together (RailTies). Although Rails is typically used as a framework (an
environment specialized to programming web applications), the components of Rails
can be replaced with other components more suitable to a project. Alternatively, the
components can be broken out and used apart from the rest of Rails. In this chapter,
we will see how these techniques can be used for maximum flexibility in application
development.
Replacing Rails Components
Replacing ActiveRecord
ActiveRecord, the Rails object-relational mapper, is one of the best-known parts of
the Rails framework. But it represents one of many valid ways to map objects to a
database. Martin Fowler identified and defined the Active Record pattern, along with
other data-source patterns, in his book Patterns of Enterprise Application Architecture.
(The Active Record pattern should not be confused with the ActiveRecord
library, which is based on that pattern.) Several Ruby libraries have been developed
based on other patterns. We will look at DataMapper, based on the pattern of the
same name. We will also examine Ambition, an off-the-wall experimental library
that maps Ruby statements directly to SQL.
If you are not using ActiveRecord in a Rails application, you can disable it by removing
it from config.
Pages:
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413