Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created December 10, 2008 05:04
Show Gist options
  • Save jugyo/34243 to your computer and use it in GitHub Desktop.
Save jugyo/34243 to your computer and use it in GitHub Desktop.
require 'rubygems'
#gem "dm-core", "=0.9.7" #=> error!
#gem "dm-core", "=0.9.8" #=> error!
require 'dm-core'
DataMapper.setup(
:default,
"sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/test.db"
)
class User
include DataMapper::Resource
property :id, Integer, :serial => true
property :key, String
has n, :items
end
class Item
include DataMapper::Resource
property :id, Integer, :serial => true
belongs_to :user
end
DataMapper.auto_migrate!
user = User.create(:key => "key")
user.items << Item.create # ここでエラーになる
user.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment