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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:29:48+00:00 2026-05-18T01:29:48+00:00

In my application I authenticate users using Devise and I noticed that you can

  • 0

In my application I authenticate users using Devise and I noticed that you can change the page that one is redirected to if the sign in fails. On the wiki I found the following example:

class CustomFailure < Devise::FailureApp
  def redirect_url
    new_user_session_url(:subdomain => 'secure')
  end

  # You need to override respond to eliminate recall
  def respond
    if http_auth?
      http_auth
    else
      redirect
    end
  end
end

Following this example I created my own CustomFailure class(custom_failure.rb) and placed in the helper folder (not sure where to put it). This is the following class I created:

class CustomFailure < Devise::FailureApp
  def redirect_url
    new_user_session_url(:subdomain => 'secure')
  end

  # Redirect to root_url
  def respond
    if http_auth?
      http_auth
    else
      root_url
    end
  end
end

I also added the following in the config/initializers/devise.rb file (as the wiki states should be done):

config.warden do |manager|
  manager.failure_app = CustomFailure
end

Although I get no errors, when I incorrectly sign in it still redirects to the /users/sign_in page (not the root page) and nothing is loaded (the page is completely white even though the source is not empty). Is there comthing wrong with my CustomFailure class or maybe it is in the wrong folder?

I am using Rails 3.0.1 and Devise 1.1.rc0.

The wiki where this code is found is at: How To: Redirect to a specific page when the user can not be authenticated

  • 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-18T01:29:49+00:00Added an answer on May 18, 2026 at 1:29 am

    Try putting custom_failure.rb into you lib folder as it is not a helper. Then make sure the file is loaded. Probably you would attempt to load all files in lib automatically.

    EDIT: To achieve an auto loaded lib you would insert the following to your application.rb:

    config.autoload_paths += %W(#{config.root}/lib)
    

    EDIT2: you forgot to call redirect_to when trying to redirect. At the moment respond only returns root_url. Try this:

    def respond
      if http_auth?
        http_auth
      else
        redirect_to root_url
      end
    end
    

    fyi: the devise-guys also perform this before redirecting:

    store_location!
    flash[:alert] = i18n_message unless flash[:notice]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an ASP .NET Membership database to authenticate users in a web application.
I have a Rails application for which I use devise to authenticate my users
I have an ASP.NET application that authenticates users using Ldap against active directory. This
I've got an HttpModule in my application that hooks into the FormsAuthenticationModule's Authenticate event
I am using a asp.net login control with one of my asp.net application to
The application my team is currently developing has a DLL that is used to
I'm building an iPhone application that talks to a Ruby on Rails backend. The
I have an application that runs on Windows Mobile 6 Professional PDA devices. The
I'm trying to authenticate a SOAP request using WS-UsernameToken spec, but the target device
I have 2 login controls on a web application one on default and one

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.