Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created December 9, 2008 21:15
Show Gist options
  • Save ashgti/34096 to your computer and use it in GitHub Desktop.
Save ashgti/34096 to your computer and use it in GitHub Desktop.
require 'rubygems'
gem 'dm-core'
require 'dm-core'
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper::Logger.new(STDOUT, :debug)
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, :debug)
class User
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :posts
end
class Post
include DataMapper::Resource
property :id, Serial
property :title, String
belongs_to :user
# has n, :comments
end
DataMapper.auto_migrate!
a = User.new :name => "hi"
a.save
a.posts.build(:title => 'test')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment