Thufir Hawat
12/27/2007 8:53:00 PM
A more complete example:
C:\code\dwemthys>
C:\code\dwemthys>
C:\code\dwemthys>gem search activerecord
*** LOCAL GEMS ***
activerecord (2.0.2, 1.15.6)
Implements the ActiveRecord pattern for ORM.
C:\code\dwemthys>
C:\code\dwemthys>ruby db_crud_create.rb
db_crud_create.rb:1:in `require': no such file to load --
active_record (LoadErr
or)
from db_crud_create.rb:1
C:\code\dwemthys>
C:\code\dwemthys>type db_crud_create.rb
require 'active_record'
require 'fileutils'
require 'creature'
require 'dragon'
require 'instantiate'
include Instantiate
system("rm dwemthys.db")
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = true
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:dbfile => "dwemthys.db"
)
ActiveRecord::Schema.define do
create_table :creatures do |table|
table.column :type, :string
table.column :life, :integer
table.column :strength, :integer
table.column :charisma, :integer
table.column :weapon, :integer
end
end
99.times do |index|
creature = Instantiate.randomCreature
p creature
creature.save
end
C:\code\dwemthys>
thanks,
Thufir