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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:26:18+00:00 2026-06-03T06:26:18+00:00

I have a very simple sign_in page for a devise user. Upon submitting incorrect

  • 0

I have a very simple sign_in page for a devise user. Upon submitting incorrect data, the log shows a ‘401 Unauthorized’ and redirects me back to the sign_in page. I couldn’t figure out a way to show error messages to the user.

I looked at devise::sessions_controller#create which is as follows,


 # POST /resource/sign_in
  def create
    resource = warden.authenticate!(auth_options)
    set_flash_message(:notice, :signed_in) if is_navigational_format?
    sign_in(resource_name, resource)
    respond_with resource, :location => after_sign_in_path_for(resource)
  end

  def auth_options
    { :scope => resource_name, :recall => "#{controller_path}#new" }
  end  

The flow gets interrupted at warden.authenticate in case of a failed authentication and the user get redirected to the ‘new’ which is the sign_in page.

I just need to show the user a invalid_credentials tooltip/flash_message. So I did it by modifying :recall => "#{controller_path}#handle_create_fail" (look at auth_options) which calls handle_create_fails when authentication fails, inside which I setup the error messages.

I am not sure if I overlooked something that devise already provides.

How can I handle this better?

  • 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-03T06:26:20+00:00Added an answer on June 3, 2026 at 6:26 am

    ‘devise’ stores error messages in rails ‘flash’, using flash[:notice] for success messages and flash[:alert] for problems.

    Here’s this from the devise documentation:

    Remember that Devise uses flash messages to let users know if sign in
    was successful or failed. Devise expects your application to call
    “flash[:notice]” and “flash[:alert]” as appropriate.

    This means that in your view file (or more generally in your application layout file) you should include something similar to these lines:

    <%= content_tag(:div, flash[:error], :id => "flash_error") if flash[:error] %>
    <%= content_tag(:div, flash[:notice], :id => "flash_notice") if flash[:notice] %>
    <%= content_tag(:div, flash[:alert], :id => "flash_alert") if flash[:alert] %>
    

    Here are some similar questions/answers:

    Rails – Devise – Error messages when signing in?

    Devise errors are displayed twice

    devise – Customizing the User Edit Pages

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

Sidebar

Related Questions

I have very simple: [PrincipalPermission(SecurityAction.Demand, Role = Administrator)] public partial class _Default : System.Web.UI.Page
I have very simple data model like this: create table Company ( id int
I have very simple window where I have 2 buttons - one for cancel,
I have a very simple webforms app that will allow field techs to order
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
I have a very simple Setup project that copies three dlls into the GAC.
I have a very simple table with two columns, but has 4.5M rows. CREATE
I have a very simple iPhone app that requires a random integer from 1-100.
I have a very simple Mac Cocoa app that just has a Web View
I have a very simple python script that should scan a text file, which

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.