Ruby Sinatra中的DataMapper错误-NameError:找不到子\u模型

Ruby Sinatra中的DataMapper错误-NameError:找不到子\u模型,ruby,sinatra,datamapper,ruby-datamapper,Ruby,Sinatra,Datamapper,Ruby Datamapper,使用Sinatra和DataMapper。这是我第一次尝试使用两个以上的模型类。不确定是什么导致了错误。谢谢 错误: NameError: Cannot find the child_model ContactNote for Contact in contact_notes 模型: class Contact include DataMapper::Resource property :id, Serial property :fullname, Text, :req

使用Sinatra和DataMapper。这是我第一次尝试使用两个以上的模型类。不确定是什么导致了错误。谢谢

错误:

NameError: Cannot find the child_model ContactNote for Contact in contact_notes
模型:

class Contact
    include DataMapper::Resource
    property :id, Serial
    property :fullname, Text, :required => true
    property :email, Text
    property :phone, Text
    has n, :contact_notes
    has n, :projects
end

class Contact_Note
    include DataMapper::Resource
    property :id, Serial
    property :contact_content, Text, :required => true
    property :created_at, DateTime
    property :updated_at, DateTime
    belongs_to :contact
end

class Project
    include DataMapper::Resource
    property :id, Serial
    property :project_name, Text, :required => true
    property :created_at, DateTime
    property :updated_at, DateTime
    belongs_to :contact
    has n, :project_notes
end


class Project_Note
    include DataMapper::Resource
    property :id, Serial
    property :project_content, Text, :required => true
    property :created_at, DateTime
    property :updated_at, DateTime
    belongs_to :project
end

Datamapper根据ruby约定对类名做出了期望。它希望您的联系人便笺位于
联系人便笺
类中,而您已将其命名为
联系人便笺
,因此无法找到联系人便笺。

谢谢。这很有效。我注意到,即使我将类更改为ContactNote,我也必须将关联属性保留为:contact\u notes。如果删除下划线,则会出现类似的错误。这是另一个datamapper约定吗?这通常是一个ruby约定。