Rails中的自定义错误页面没有显示过期资产(已不存在)的漂亮404



当出现错误500或404时,我会向用户显示漂亮的错误页面(示例)。我遵循了本指南,它适用于已不存在的页面,但不适用于过期资产(已不存在),即/assets/wood_bg2-7ab28512ecf6eeeb5f3742abca48a7b5.png等图像。对于这些图像,将显示一个"空"one_answers"丑陋"的缺失图像(示例),而不是我的自定义404错误页面。

我通过exception_notification-gem:得到的错误

An ActionView::MissingTemplate occurred in errors#error_404: Missing template errors/error_404, application/error_404 with {:locale=>[:en], :formats=>[:png], :handlers=>[:erb, :builder, :coffee, :haml]}. 

所以,也许我只需要"告诉"错误页面/路由,它也应该显示我的png、jpg等文件的错误页面?

有什么办法解决的吗?

感谢:)

我曾经实现过nifty_errorpages gem。它在github上可用:https://github.com/mattherick/nifty_errorpages.也许我的实现可以帮助你解决问题。它适用于轨道3.2。如果你有3.1,请简单地查看源代码,否则你可以将其添加到你的Gemfile中并直接试用。

最新更新