2010-03-02 27 views
3

这可能很简单,但我不明白为什么我没有得到错误页面。导轨404 422 500完全空白

首先,我使用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 

回答

3

我不认为Heroku的使用.html文件像乘客或杂种狗做的细节。您可能需要通过两个基本机制来捕获并处理自己的异常:

  • 在你的ApplicationController任何可能发生爆炸,都具体而直至并包括对象创建rescue_from异常处理程序。
  • 创建默认路由以捕获任何未被路由的内容。

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

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

+0

你可能是对的。我添加了一个rescue_action_in_public方法,它似乎能够完成这项工作,但我仍然想知道是否有更好的方法可以让我自己发明轮子? – holden 2010-03-02 19:29:59