Custom Error Page - Ruby on Rails

我与影子孤独终老i 提交于 2019-11-28 18:27:35
Reza Hashemi

You can do that with route globbing in rails, It lets you match any action to any part of a route using wildcards.

To catch all remaining routes, just define a low priority route mapping as the last route in config/routes.rb:

In Rails 3: match "*path" => 'error#handle404'

In Rails 2: map.connect "*path", :controller => 'error', :action => 'handle404'

params[:path] will contain the matching part.

If you don't need dynamic error pages, just edit public/404.html and public/505.html. If you do, see Reza.mp's answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!