如何渲染404或页面不像Twitter那样存在?我使用导轨 3.2.3
我的代码
def rescue_with_handler(exception)
redirect_to '/500.html'
end
def method_missing(id, *args)
redirect_to '/404.html'
end
这行得通,但我想像推特一样。例如,如果我访问此页面https://twitter.com/abcd/skka/asafaga和 https://twitter.com/abcd/skka
你必须用rescue_from
来处理Routing Error
。
这个问题已经回答了:
- Rails 3 中的动态错误页面
- 使用DataMapper处理Rails3控制器中的404的最佳方法
- rescue_from 无方法错误
- 。
这里也有解决方案:
- https://github.com/rails/rails/issues/671
无论如何,尝试谷歌它,你会发现很多不同的解决方案。