I am trying an example on the page http://ruby.about.com/od/sinatra/a/datamapper.htm. I copied the following code from the web site:
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
DataMapper.setup(:default, "sqlite3:///tmp/test1.db")
class Person
include DataMapper::Resource
property :firstname, String
property :lastname, String
property :email, String, :key => true
end
p = Person.new
p.attributes = {
:firstname => 'John',
:lastname => 'Doe',
:email => 'john.doe@email.com'
}
Running this code by ruby test.rb
, I got an error message
/usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:335:in `block in attributes=': undefined method `include?' for nil:NilClass (NoMethodError)
from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:332:in `each'
from /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:332:in `attributes='
from test.rb:16:in `<main>'
What am I doing wrong? Thanks.