Custom Error Page - Ruby on Rails

后端 未结 2 865
不思量自难忘°
不思量自难忘° 2020-12-13 16:25

I am trying to setup a custom error page in my website. I am following the guidelines atPerfectLine Blog.

It works in the case where the controller exists, but the

相关标签:
2条回答
  • 2020-12-13 16:51

    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.

    0 讨论(0)
  • 2020-12-13 17:12

    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.

    0 讨论(0)
提交回复
热议问题