 
 This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
| Databases and Persistence | ||
|---|---|---|
| Code | Expected | Actual | 
| require 'rubygems'
require 'dbi'
require_gem 'activerecord'
require 'og'
def with_db
  DBI.connect("dbi:Mysql:cookbook:localhost", 
              "cookbook_user", "password") do |c|
    yield c
  end
end
def activerecord_connect
  ActiveRecord::Base.establish_connection(:adapter => "mysql",
                                          :host => "localhost",
                                          :username => "cookbook_user",
                                          :password => "password",
                                          :database => "cookbook")
end
def og_connect
  Og.setup( {:destroy => false,
              :store => :mysql,
              :user => "cookbook_user",
              :password => "password",
              :name => "cookbook" } )
end | nil | |