Phusion Passenger 错误“未知密钥:通过”
我的 Rails 应用程序在本地测试服务器上运行良好,但是当我部署到生产(Passenger)服务器时,出现以下错误:
Error message:
Unknown key(s): through
Exception class:
ArgumentError
为什么会发生这种情况?该代码不可能存在固有缺陷,因为在开发服务器上一切正常。有问题的代码非常简单:
class PageEvent < Event
belongs_to :page, :through => :calendar
end
where
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
My rails application runs fine on my local testing server, but when I deploy to my production (Passenger) server, I get the following error:
Error message:
Unknown key(s): through
Exception class:
ArgumentError
Why might this be happening? The code can't be inherently flawed, since everything works fine on the development server. The offending piece of code is very simple:
class PageEvent < Event
belongs_to :page, :through => :calendar
end
where
class Event < ActiveRecord::Base
belongs_to :calendar, :polymorphic => true
end
and
class Calendar < ActiveRecord::Base
has_many :events, :dependent => :destroy, :inverse_of => :calendar, :as => :calendar, :class_name => "SpecialEvent"
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能说它似乎在开发中工作,但没有
belongs_to :through
发生了什么。http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods。 html#method-i-belongs_to
I can't say what is happening that it appears to be working in dev, but there is no
belongs_to :through
.http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-belongs_to