I am unable to determine why I am getting a name error here. I’m new to DataMapper, but trying to associations down. Any help is appreciated.
User:
class User
include DataMapper::Resource
property :id, Serial, :key => true
property :first_name, String
property :last_name, String
property :company, String
property :city, String
property :country, String
property :mobile_number, Integer
property :email_address, String
property :shahash, String
property :isRegistered, Boolean
belongs_to :event, :required => true
end
DataMapper.auto_upgrade!
Event:
class Event
include DataMapper::Resource
property :id, Serial, :key => true
property :name, String
property :occuring, DateTime
has n, :user
end
DataMapper.auto_upgrade!
I think the problem is you’re calling
DataMapper.auto_upgrade!after each model definition. When you call it after just defining one model, there’s no child model there. Instead, you should define and/or require all your models and then do: