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 384803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:24:58+00:00 2026-05-12T15:24:58+00:00

What I want to do: redirect the user to a special error page if

  • 0

What I want to do: redirect the user to a special error page if the database is down.

I’m using an Oracle database with the OCI adapter.

It appears that, if the database is unavailable (say, down for backup), that the OCI adapter throws an error before I ever hit a controller (based on the stack trace, it’s while it’s setting up the connection pool). So I can’t use rescue_from or rescue_action, even in ApplicationController — the rescue line is never reached.

Is there any way to “wrap” the initialization or otherwise rescue a particular error at a higher level (or earlier point) than ApplicationController?

  • 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-05-12T15:24:58+00:00Added an answer on May 12, 2026 at 3:24 pm

    Try overriding ActionController::Failsafe, or sticking another middleware before it on the stack, you should be able to catch almost all exceptions from there, and 302 at will.

    Example:

    class DbFailsafe
      def new(app)
        @app = app
      end
    
      def call(env)
        @app.call(env)
      rescue DataBaseError => e
        [302, {"Content-Type" => "text/plain", "Location" => "http://otherserver.com/sorrt-the-site-is-down.html"}, ["You are being redirected to http://otherserver.com/sorrt-the-site-is-down.html"]]
      end
    end
    

    and in your environment.rb

    config.middleware.insert_after ::ActionController::Failsafe, DbFailsafe
    

    I’d recommend (because a we should be returing a 5xx not a 3xx) rendering a simple page with a js redirect. This is simple to do, just edit public/500.html.

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

Sidebar

Related Questions

I want to redirect the user to a custom error page when s/he is
I want to redirect users to an error page if they enter any URL
I want to redirect to error page if the requested URI comes up with
When I want to redirect a user to a specific page behind a login
You know that if you want to redirect a user in PHP you can
I'm using TYP 4.5.5, RealURL 1.11.2 and tt_news 3.0.1. I want that the user
In my website I want to redirect the user to the same page on
I want to redirect a user who gets from page.php?letter=A&num=2 to the following address:
How can I redirect a user to home page? Example: mywebsite.example/ddfdf/fdfdsf and I want
I want to redirect user to a selected page if they use Any Version

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.