Crap... I pasted the wrong example. Here is the one with Migration
that doesn't work.
-----------------------------------------------
require 'rubygems'
require "sequel"
require "logger"
DB = Sequel.sqlite '', :logger => [Logger.new($stdout)]
class CreateBp < Sequel::Migration
def up
create_table :bps do
primary_key :id
text :name
end
end
end
class CreateStatistic < Sequel::Migration
def up
create_table :statistics do
primary_key :id
foreign_key :bp_id, :table => :bps
integer :waiting
end
end
end
class Bp < Sequel::Model
one_to_many :statistics
end
class Statistic < Sequel::Model
many_to_one :bp
end
CreateBp.apply(DB, :up)
CreateStatistic.apply(DB,:up)
bp = Bp.create(:name => "Order")
statistic = Statistic.create(:waiting => rand*100)
bp.add_statistic(statistic)
bp.statistic.each do |stat|
puts "stat: " + stat[:waiting].to_s
end
------------------------------------------------------------
Best regards,
Morten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---