Phusion Passenger 错误“未知密钥:通过”

发布于 2024-12-01 04:56:31 字数 666 浏览 1 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2024-12-08 04:56:31

我不能说它似乎在开发中工作,但没有 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文