Skip to content

Instantly share code, notes, and snippets.

@wycats
Created August 6, 2008 01:17
Show Gist options
  • Save wycats/4146 to your computer and use it in GitHub Desktop.
Save wycats/4146 to your computer and use it in GitHub Desktop.
require "rubygems"
require "dm-core"
DataMapper.setup(:default, "sqlite3::memory:")
class Category
include DataMapper::Resource
property :id, Serial
has n, :items
end
class Item
include DataMapper::Resource
property :id, Serial
property :category_id, Integer
belongs_to :category
end
DataMapper.auto_migrate!
Item.create(:category_id => 25)
Item.first.category
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment