Не удается найти child_model - спасение в child_model - PullRequest
0 голосов
/ 06 июля 2011

Я получаю приведенную ниже ошибку со следующими моделями. Я в недоумении, почему. Любая помощь с благодарностью.

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 голосов
/ 07 июля 2011

Куда вы звоните DataMapper.finalize/auto_upgrade?Похоже, у тебя какая-то проблема с курицей и яйцом.Вы должны требовать все свои модели в одном месте, прежде чем позвонить finalize + auto_upgrade.

...