title: Rails - Devise sign in / authentication failure does not populate errors array with message
body: <p>Using Rails 3.07 and Devise 1.1.5</p>
  
  <p>Everything is working fine and as expected with one exception. When a user tries to login with a bogus password, for instance, devise denies the login attempt, which is correct, but fails to provide an error message. </p>
  
  <p>I have several error display methods set up in app/helpers/devise_helper.rb and I am using one called devise_sign_in_error_messages! for the login view. Therefore I am able to verify that the following line from that function is returning a blank string for errors in this case:
      return "" if resource.errors.empty?</p>
  
  <p>If I give a correct username and password, the system logs me in just fine, so all of the devise logic seems fine, it's just this lack of an error message that's a mystery.</p>
  
  <p>What do I need to change to help devise pass me an error message on failed login? </p>
  
  <p>EDIT:</p>
  
  <p>The answer is that:
  a) devise is sticking the answer in flash
  b) even though it's in flash, it's not using the key you might expect</p>
  
  <p>Using this bit of code, I can see the message:</p>
  
  <pre><code>&lt;% flash.each do |name, msg| %&gt;
  &lt;%= content_tag :div, msg, :id =&gt; "flash_#{name}" if msg.is_a?(String) %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Which I came across on a different post as an answer to a different question:
  <a href="https://stackoverflow.com/questions/4101641/rails-devise-handling-devise-error-messages/">Another stack overflow post</a></p>
  
  <p>I had tried to output the flash earlier but did not see the message because I followed a bit of code from a different stack overflow post that appears to be insufficient. Namely, I had tried:</p>
  
  <pre><code>&lt;%= flash[:message] if flash[:message]
  flash[:warning] if flash[:warning]
  flash[:error] if flash[:error] %&gt;
  </code></pre>
  
  <p>Devise is not using these keys for the login error message so this code will get you nothing. </p>
  
  <p>I find devise's handling of this to be inconsistent. Specifically, if I choose devise's forgot password option and enter a bogus email address for instance, the error gets passed back in the resource.errors array, but here with the bad login it gets passed in flash.</p>