Hoopla! » Rails: Custom 404 Pages
there is another more generic way that will catch all the errors, you can inspect the exception to route to the right view, and possibly log the trace: in application.rbthanks for the CSV tip. doc is atrociousdef rescue_action_in_public(exception) # do something based on exception message = exception.backtrace.join("\n") unless exception render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404 end def local_request? false end
via 6brand.com
覆寫「rescue_action_in_public」來處理 global 的 exception。