富松乘客错误'Unknown key(s): through'



我的rails应用程序在本地测试服务器上运行良好,但是当我部署到生产(Passenger)服务器时,我得到以下错误:

Error message:
  Unknown key(s): through
Exception class:
  ArgumentError

为什么会发生这种情况?代码不可能存在固有缺陷,因为在开发服务器上一切都运行良好。这段违规的代码非常简单:

class PageEvent < Event
   belongs_to :page, :through => :calendar
end

,

class Event < ActiveRecord::Base
  belongs_to :calendar, :polymorphic => true
end

class Calendar < ActiveRecord::Base
  has_many :events, :dependent => :destroy, :inverse_of => :calendar, :as => :calendar, :class_name => "SpecialEvent"
end

我不能说发生了什么,它似乎在开发中工作,但没有belongs_to :through

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html method-i-belongs_to

最新更新