3

这可能很简单,但我不知道为什么我没有收到错误页面。

首先,我使用 Heroku 进行托管,所以它肯定处于生产模式。

如果我将“config.action_controller.consider_all_requests_local”行设置为 true,我会收到详细的错误消息,否则,我会收到一个完全 100% 的空白屏幕。如果我查看源代码,也是空白。

我所有的 404,422,500.html 文件都是公开的,我没有碰过它们。

如果我在那里以生产模式开始,它们似乎可以在我的本地机器上工作。所以它必须与Heroku有关?有任何想法吗?

日志告诉我没有任何用处。

以下是 production.rb 文件的详细信息

config.cache_classes = true

#ActionMailer::Base.delivery_method = :sendmail
Paperclip.options[:command_path] = "/usr/bin/"

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# set delivery method to :smtp, :sendmail or :test
config.action_mailer.delivery_method = :smtp

# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching             = true
config.action_view.cache_template_loading            = true
4

1 回答 1

3

我不认为 Heroku 使用像 Passenger 或 Mongrel 这样的 .html 文件。您可能需要通过两种基本机制来捕获和处理自己的异常:

  • 在你的 ApplicationController 中为任何可能爆炸的东西创建一个异常处理程序,包括对象。
  • 创建一个默认路由以捕获未路由的任何内容。

如果您退出路由表,或触发“500”错误,那是因为异常。这些都需要处理,否则您将看到一个空白屏幕,除非 Web 服务器另外配置。

可以使用 ErrorDocument 指令将 Apache 配置为执行此操作。

于 2010-03-02T19:07:11.247 回答