Skip to content

Instantly share code, notes, and snippets.

@adelcambre
Forked from carllerche/dm-bug.rb
Created January 30, 2009 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adelcambre/55240 to your computer and use it in GitHub Desktop.
Save adelcambre/55240 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -KU
require "rubygems"
require "dm-core"
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.setup(:second, "sqlite3:///#{File.dirname(__FILE__)}/test.db")
class Customer
include DataMapper::Resource
def self.default_repository_name ; :default ; end
property :id, Serial
property :name, String
def contact
DataMapper.repository(:second) do
Contact.first(:name => name)
end
end
end
class Contact
include DataMapper::Resource
def self.default_repository_name ; :second ; end
property :id, Serial
property :name, String
end
Customer.auto_migrate!(:default)
Contact.auto_migrate!(:second)
contact = Contact.create(:name => "carl")
customer = Customer.new(:name => "carl")
customer.update_attributes(:name => customer.contact.name)
raise "FAIL" if customer.class.repositories.inspect.include?("second")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment