1

Sinatra と DataMapper を使用します。2 つ以上のモデル クラスを使用するのはこれが初めてです。エラーの原因がわかりません。ありがとう。

エラー:

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
4

1 に答える 1

3

Datamapper は、Ruby の規則に基づいてクラス名を期待します。名前を付けている間、連絡先メモがContactNoteクラスにあると想定しているContact_Noteため、ContactNoteが見つからないというエラーが発生します。

于 2012-12-29T23:36:18.220 に答える