Created
July 12, 2010 11:01
-
-
Save yannick/472363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'datamapper' | |
class Person | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
has n, :managers, 'Person', :through => Resource | |
has n, :managees, 'Person', :through => :managers, :child_key => [:person_id] | |
end | |
DataMapper.setup :default, 'sqlite3::memory:' | |
DataMapper.auto_migrate! | |
user1 = Person.create(:name => 'Dan Kubb') | |
user2 = Person.create(:name => 'John Doe', :managers => [ user1 ]) | |
user1.save! | |
user2.save! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment