Skip to content

Instantly share code, notes, and snippets.

@gcampbell
Created December 17, 2009 00:48
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 gcampbell/258387 to your computer and use it in GitHub Desktop.
Save gcampbell/258387 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'dm-core'
DataMapper.setup(:default, 'sqlite3::memory:')
class GameConsole
include DataMapper::Resource
property :id, Serial
property :type, Discriminator
def producer
"invalid"
end
end
class Wii < GameConsole
def producer
"Nintendo"
end
end
class XBox < GameConsole
property :xbox_live, Boolean
def producer
"Microsoft #{xbox_live}"
end
end
DataMapper.auto_migrate!
XBox.create(:xbox_live => true)
Wii.create
# The next line causes the following error:
# /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/query.rb:803:in `assert_valid_fields': +options[:field]+ entry :xbox_live does not map to a property in GameConsole (ArgumentError)
GameConsole.all.map {|gc| gc.producer}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment