Permalink
Browse files

#96 - Redirect ActionController::UnknownFormat errors to 404 page

  • Loading branch information...
1 parent 4467a93 commit 5846e94d039ea67d56281e6f8ed87b2f5ce4c52b @andey committed Jan 25, 2014
Showing with 9 additions and 3 deletions.
  1. +7 −0 app/controllers/application_controller.rb
  2. +2 −3 public/404.html
@@ -1,7 +1,14 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+ rescue_from "ActionController::UnknownAction", :with => :render_404
+ rescue_from "ActionController::UnknownFormat", :with => :render_404
+ rescue_from "ActionController::RoutingError", :with => :render_404
def raise_404
raise ActionController::RoutingError.new('Not Found')
end
+
+ def render_404
+ redirect_to '/404'
+ end
end
View
@@ -30,9 +30,8 @@
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
- <h1>The page you were looking for doesn't exist.</h1>
-
- <p>You may have mistyped the address or the page may have moved.</p>
+ <h1>404</h1>
+ <p>The page you were looking for doesn't exist.</p>
</div>
</body>
</html>

0 comments on commit 5846e94

Please sign in to comment.