开发者

Cannot find the child_model - rescue in child_model

I'm getting the below error with the following models. I'm at a loss as to why. Any help is greatly appreciated.

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'

Document 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

Event Model:

# 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,开发者_JS百科 :required => false
end


Where are you calling DataMapper.finalize/auto_upgrade? It sounds like you have some sort of chicken and egg problem. You need to require all your models in one place before you call finalize + auto_upgrade.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜