Login failure flash message not appearing

2,201 views
Skip to first unread message

Adam

unread,
Mar 9, 2010, 1:10:08 AM3/9/10
to Devise
Devise is more or less working fine (I can sign up, log in, log out,
etc.).

However, login-failure flash messages are never appearing.
When I enter a known-bad email address (for example), the :invalid
flash message never appears.

I've debugged this in sessions_controller.rb
(SessionsController#create), and the flash message is getting set
properly to :invalid (or rather, its correct I18n translation 'Invalid
email or password.').

The view produces "<p style='color: green'></p>" is if it wants to say
something, but the <p> is empty.

I'm using ruby 1.8.7 on Mac Snow Leopard, Rails 2.3.5, Devise 1.0.4,
Warden 0.9.6. (Same behavior under 1.0.1)

Bright ideas anyone?

thanks,

Adam

José Valim

unread,
Mar 9, 2010, 6:03:43 AM3/9/10
to plataforma...@googlegroups.com
You need to configure it to display the flash message. By default, Rails scaffold only shows flash[:notice] and Devise sets flash[:alert]. You have to change your view to show flash[:alert] as well.
--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/

Carlos A. da Silva

unread,
Mar 9, 2010, 6:07:00 AM3/9/10
to Devise
Devise uses the keys :notice and :alert for flash messages. We haven't
experienced any issue so far.
Be sure you are handling this flash messages under your layout or
template.

--
Carlos Antonio

Adam

unread,
Mar 9, 2010, 11:53:01 AM3/9/10
to Devise
I get it. Thanks very much guys.

I'm guessing that it's conventional in the Rails world to have
something like this in your app/views/layouts/application.html.haml:

- if flash[:notice]
%p(style="color: green")= flash[:notice]
- if flash[:alert]
%p(style="color: red")= flash[:alert]

??

On Mar 9, 6:07 am, "Carlos A. da Silva"

José Valim

unread,
Mar 9, 2010, 12:06:53 PM3/9/10
to plataforma...@googlegroups.com
Yes, I'm going to add it.
Reply all
Reply to author
Forward
0 new messages