Запрос Rails ActiveRecord выбрасывает неопределенную ошибку BelongsToAssociation - PullRequest
1 голос
/ 20 марта 2011

У меня есть Публикация модели Rails 2.3, которая содержит версию ассоциации own_to. Когда я запускаю эту активную запись, обнаруживаю, что она работает в первый раз, но при обновлении страницы выдается ошибка undefined method version 'для # `.

Publication.find(:all, :limit => 10, :order => "date_published desc", 
    :include => [:version => {:work => :work_type}, 
                 :products => {:media_type => :meaning} ])

class Publication < ActiveRecord::Base
  acts_as_nested_set

  belongs_to :imprint
  has_many :products
  has_many :subscriptions
  belongs_to :cover_image
  belongs_to :version

  accepts_nested_attributes_for :products, :allow_destroy => true
  accepts_nested_attributes_for :subscriptions, :allow_destroy => true
  accepts_nested_attributes_for :cover_image, :allow_destroy => true
  accepts_nested_attributes_for :version
end



class Version < ActiveRecord::Base
  belongs_to :work

  has_many(:authorships, :as => :authorable, :include => [:role])
  has_many(:user_authorships, :as => :authorable, 
            :conditions => { :authorizable_type => "User" })
  has_many(:organization_authorships, :as => :authorable, 
            :conditions => { :authorizable_type => "Organization" })

  has_one :element, :class_name => "Element", :foreign_key => :version_id

  has_many :tag_links, :as => :taggable, :class_name => 'TagLink'
  has_many :tags, :through => :tag_links, :class_name => 'Tag'

  accepts_nested_attributes_for :authorships, :allow_destroy => true
  accepts_nested_attributes_for :work
end
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...