2010-03-02 51 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