-
-
Save harssh/7478837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyApp | |
class Application < Rails::Application | |
require Rails.root + 'lib/custom_public_exceptions' | |
config.exceptions_app = CustomPublicExceptions.new Rails.public_path | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomPublicExceptions < ActionDispatch::PublicExceptions | |
def call(env) | |
status = env["PATH_INFO"][1..-1] | |
if "404" == status | |
# handle just 404 in our routes | |
MyApp::Application.routes.call env | |
else | |
super env | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ErrorsController < ApplicationController | |
skip_before_filter :authenticate_user! # if using Devise | |
def not_found | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Geknowm::Application.routes.draw do | |
match "/404", :to => "errors#not_found" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment