Skip to content

Instantly share code, notes, and snippets.

@turadg
Last active August 1, 2024 08:35

Revisions

  1. Turadg Aleahmad revised this gist May 15, 2013. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  2. Turadg Aleahmad revised this gist May 13, 2013. No changes.
  3. Turadg Aleahmad created this gist May 13, 2013.
    7 changes: 7 additions & 0 deletions errors_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    class ErrorsController < ApplicationController
    skip_before_filter :authenticate_user! # if using Devise

    def not_found
    end

    end
    14 changes: 14 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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
    6 changes: 6 additions & 0 deletions gistfile2.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    module MyApp
    class Application < Rails::Application
    require Rails.root + 'lib/custom_public_exceptions'
    config.exceptions_app = CustomPublicExceptions.new Rails.public_path
    end
    end
    3 changes: 3 additions & 0 deletions routes.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Geknowm::Application.routes.draw do
    match "/404", :to => "errors#not_found"
    end