Rails 3 - 自定义错误 &404页 [英] Rails 3 - Customizing the Error & 404 pages
问题描述
我正在 Heroku 上构建 Rails 3 应用程序.现在我的错误页面和 404 页面都是标准的 rails/heroku 页面.
I'm building a Rails 3 app on Heroku. Right now my error pages and 404 page are all standard rails/heroku pages.
我想自定义这两个.有一个错误页面,一个 404 页面.
I'd like to customize these two. Have a page for an error, and have a page for a 404.
在 google 上找到的所有教程都是多年以前的,并且不适用于 Rails 3.
All the tutorials found on google are years old, and don't work on Rails 3.
能否请您推荐一个很好的现代教程或有关如何执行上述操作的提示?
Can you please suggest a good modern tutorial or tips on how to do the above?
谢谢
推荐答案
如果要捕获特定错误,请使用 rescue_from
在 ApplicationController
中.
If you want to capture specific errors, use rescue_from
in ApplicationController
.
否则,如果您只想编辑默认错误页面,请编辑 {Rails.root}/public 中的 500.html 和 400.html 文件
Otherwise if you just want to edit the default error pages, edit the 500.html and 400.html files in {Rails.root}/public
这篇关于Rails 3 - 自定义错误 &404页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!