Created
December 17, 2009 00:48
-
-
Save gcampbell/258387 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 '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