Replacing Rails Components | 277
Then we can build the Glue and Og (and, optionally, Raw and Nitro) libraries into
gems and install them:
$ cd glue/
$ gem build glue.gemspec
$ sudo gem install glue-0.50.0.gem
$ cd ../og/
$ gem build og.gemspec
$ sudo gem install og-0.50.0.gem
$ cd ../raw/
$ gem build raw.gemspec
$ sudo gem install raw-0.50.0.gem
$ cd ../nitro/
$ gem build nitro.gemspec
$ sudo gem install nitro-0.50.0.gem
To update the beta gem to the latest source, you can later rundarcs
pullfrom thenitroprojectdirectory. Then recheck the Facets depen-
dency, and run the preceding code again to rebuild and reinstall the
latest gems.
Verify that the Og gem is correctly installed:
$ gem list --local og
*** LOCAL GEMS ***
og (0.50.0)
State of the art object-relational mapping system
Using Og with Rails. We will use a custom Rails initializer to load Og and work around
a few of its Rails incompatibilities. All Ruby files inconfig/initializersare loaded auto-
matically on Rails startup, so this is a perfect place to start Og. Here is the initializer:
config/initializers/og.rb
1. Require our custom edge version of Og
gem 'og', '=0.50.0'
# 2. Work around the RubyGems / Dependencies version of require
class Object
alias_method :require_with_rubygems, :require
alias_method :require, :gem_original_require
require_with_rubygems 'og'
# Restore the Dependencies require for future require calls
alias_method :require, :require_with_rubygems
end
# 3. Define autoload path so the model can find the Orderable mixin.
# This is relative to $LOAD_PATH, which includes the lib path in the og
# gem directory.