Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Forked from adhusson/gist:97445
Created April 18, 2009 05:23
Show Gist options
  • Save knowtheory/97448 to your computer and use it in GitHub Desktop.
Save knowtheory/97448 to your computer and use it in GitHub Desktop.
%w[rubygems dm-core].each { |g| require g.to_s }
DataMapper.setup(:default, 'sqlite3::memory:')
class Something
include DataMapper::Resource
property :id, Serial
property :p1, String
property :p2, String
attr_accessor :pv
end
DataMapper.auto_upgrade!
a = Something.new(:p1 => "property one", :p2 => "property 2", :pv => "property virtual")
a.save
# => true
b = Something.new(:p1 => "property one", :p2 => "property 2", :pv => "property virtual")
b.update
# => NoMethodError: undefined method  model for nil:NilClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment