$: << File.dirname(__FILE__)
require "connect"
require "logger"

#ActiveRecord::Base.logger = Logger.new(STDOUT)

require "rubygems"
require_gem "activerecord"

class Order < ActiveRecord::Base
  has_one :invoice
end

class Invoice < ActiveRecord::Base
  belongs_to :order
end

order = Order.find(300)

invoice = Invoice.new
if invoice.save
  order.invoice = invoice
else
  fail invoice.errors.to_s
end

o = Order.new
p o.id
invoice.order = o
p o.id
invoice.save
p o.id


