Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:04:15+00:00 2026-06-09T13:04:15+00:00

I use exception_notification gem for handling an errors in an app. My ApplicationController looks

  • 0

I use exception_notification gem for handling an errors in an app.
My ApplicationController looks like this:

unless Rails.application.config.consider_all_requests_local
    rescue_from Exception,
                :with => :render_error
    rescue_from ActiveRecord::RecordNotFound,
                :with => :render_not_found
    rescue_from ActionController::RoutingError,
                :with => :render_not_found
    rescue_from ActionController::UnknownController,
                :with => :render_not_found
    rescue_from ActionController::UnknownAction,
                :with => :render_not_found
  end

  def render_not_found(exception)
    ExceptionNotifier::Notifier
      .exception_notification(request.env, exception)
      .deliver
    render :template => "/errors/404.html.erb",
      :layout => 'errors.html.erb'
    return     
  end

  def render_error(exception)
    ExceptionNotifier::Notifier
      .exception_notification(request.env, exception)
      .deliver
    render :template => "/errors/500.html.erb",
           :layout => 'errors.html.erb'
    return
  end

In /config/enviroments/productions.rg in the end of the file I have:

config.middleware.use ExceptionNotifier,
  :email_prefix => "[MY APP| Error Report] ",
  :sender_address => %{"MY APP" <err@my-app.com>},
  :exception_recipients => 'my_email@gmail.com'
end

when I get the error on the app – eg. Article.find(not-existing-ID), I’ll get the standard error page (ERROR 500) from /public/500.html and not from the file specified in application controller… How is that possible? Past hours I tried to find the problem, but I still don’t know the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:04:16+00:00Added an answer on June 9, 2026 at 1:04 pm

    This works for me – from application_controller.rb:

    unless Rails.application.config.consider_all_requests_local
      rescue_from Exception, with: :render_500
      rescue_from ActionController::RoutingError, with: :render_404
      rescue_from ActionController::UnknownController, with: :render_404
      rescue_from ActionController::UnknownAction, with: :render_404
      rescue_from ActiveRecord::RecordNotFound, with: :render_404
    end
    

    and

      private
      def render_404(exception)
        ExceptionNotifier::Notifier.exception_notification(request.env, exception,
          :data => {:User => current_user.full_name, :Email => current_user.email, :UserID => current_user.id}).deliver
        @not_found_path = exception.message
        respond_to do |format|
          format.html { render template: 'pages/404', layout: 'layouts/application', status: 404 }
          format.all { render nothing: true, status: 404}
        end
      end
      def render_500(exception)
        ExceptionNotifier::Notifier.exception_notification(request.env, exception,
          :data => {:User => current_user.full_name, :Email => current_user.email, :UserID => current_user.id}).deliver
        @error = exception
        respond_to do |format|
          format.html { render template: 'pages/500', layout: 'layouts/application', status: 500 }
          format.all { render nothing: true, status: 500}
        end
      end
    

    Note: I have my custom error pages in /app/views/pages. Called 500.html.haml and 404.html.haml

    I also have this in my routes.rb (note a hash after ‘pages rather than a forward-slash):

      unless Rails.application.config.consider_all_requests_local
        match '*not_found', to: 'pages#404'
      end
    

    PS. See updated instructions here: http://ramblinglabs.com/blog/2012/01/rails-3-1-adding-custom-404-and-500-error-pages

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use Exception Notifier for handling errors in my app and in /config/initializers/exception_notification.rb I
I'd like to use boost::signals2 to handle event notification in my C++ app. I'm
I want to use custom exception handling, for example instead of using (Exception ex)
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I am trying to use nunits new way of exception handling but I am
I would like to handle out of memory errors in iPhone to execute logic
I would like to use Atmosphere in one of my projects and have some
In my C# application I'm trying to use the TDM_CLICK_BUTTON message to click a
I'm trying to use custom notifications in my Android application using Google's sample from
I have a simple rails application with a few controller and some rake tasks.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.