在child_model中找不到child_model - rescue

时间:2011-07-06 18:48:15

标签: ruby sinatra datamapper

我在以下型号中遇到以下错误。我不知道为什么。非常感谢任何帮助。

Cannot find the child_model Document for Event in documents /usr/local/rvm/gems/ruby-1.9.2-p180/gems/dm-core-1.1.0/lib/dm-core/associations/relationship.rb:173:in 'rescue in child_model'

文档模型:

# encoding: utf-8

class Document
  include DataMapper::Resource
  include Paperclip::Resource

  timestamps :at

  property :id,                 Serial
  property :name,               String, :required => true
  property :doc_file_name,      String, :length => 255
  property :doc_content_type,   String, :length => 255
  property :doc_file_size,      Integer
  property :doc_updated_at,      DateTime
  has_attached_file :doc, :url => "/doc/:attachment/:id/:basename.:extension", :path => "#{settings.root}/public/doc/:attachment/:id/:basename.:extension"

  belongs_to :event

  validates_attachment_presence :doc
end

活动模型:

# encoding: utf-8
class Event
  include DataMapper::Resource
  timestamps :at

  property :id,          Serial
  property :name,        String, :required => true
  property :occuring,    DateTime, :required => true

  has n, :documents
  has n, :contacts
  has n, :users
  has n, :agendas
  has n, :questionnaires
  has n, :entries, :required => false
end

1 个答案:

答案 0 :(得分:0)

你在哪里打DataMapper.finalize/auto_upgrade?听起来你有某种鸡和蛋的问题。在致电finalize + auto_upgrade之前,您需要在一个地方要求所有模型。