Devise - alert messages not showing up

Hi everyone! I have installed Devise under the following settings:

  • Rails 3.0.0.
  • Ruby version: 1.9.2p0 (2010-08-18 revison 29036).
  • Ubuntu 10.04.
  • Devise version: 1.1.2

It appears the alert messages are not being displayed. The notices are
being displayed, no problem with those.
Has anyone noticed this in the meantime perhaps?

Thank you!

are you looping the flash messages?

flash.each do |name, msg|

Yes.

I don’t have any styles yet, just pure markup :slight_smile:

check your css to see if you are using flash_warning instead of
flash_alert
for the styling

can you paste the code where you loop the flash in the view?

are you able to flash[:alert] by other means?

On Tue, Sep 21, 2010 at 7:14 AM, José Mota [email protected] wrote:

Hi everyone! I have installed Devise under the following settings:

  • Rails 3.0.0.
  • Ruby version: 1.9.2p0 (2010-08-18 revison 29036).
  • Ubuntu 10.04.
  • Devise version: 1.1.2

It appears the alert messages are not being displayed. The notices are
being displayed, no problem with those.
Has anyone noticed this in the meantime perhaps?

I might be having a similar issue, if I try to sign in (using Devise),
I do not get a message of anything happening if the login is
incorrect. (I assume some kind of error message should show up?)

If I’m on the login screen however and I do something wrong I do get
proper error notices showing up.


Rick R

@Rick: What do you mean by “if I try to sign in (using Devise)” and
“If I’m on the login screen however”?
Are trying to sign in a Model from another controller and you redirect
back if login was not successful?
Everything works fine for me.

One more thing, make sure you set the flash messages explicitly if you
are overriding default Devise controllers’ actions.

On Tue, Sep 21, 2010 at 11:17 PM, tundrax [email protected] wrote:

@Rick: What do you mean by “if I try to sign in (using Devise)” and
“If I’m on the login screen however”?

Sorry I screwed up the terminology a bit. I’m using :confirmable and
there is a screen where you can “sign up” which sends out a
registration email. This screen produces errors as expected. For
example if I use an existing email, I’ll get proper errors:

http://dl.dropbox.com/u/86998/signup.png

However the by “sign in” screen I mean the main login screen. Here is
a screen shot of it - note here I entered an invalid login and I’m
getting no message:

http://dl.dropbox.com/u/86998/signin.png

Are trying to sign in a Model from another controller and you redirect
back if login was not successful?

I don’t think I’m doing anything out of the ordinary (but I’m a newb
so possibly I am?) I’m using the standard views created by Devise (I
generated them and did add one field “name”)

One more thing, make sure you set the flash messages explicitly if you
are overriding default Devise controllers’ actions.

I haven’t overridden any of Devices controllers.

Thanks for trying to help. I’m sure it’ll be something stupid.

being displayed, no problem with those.
Rick R


You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Rick R

@Rick: Erros on “sign up” page are form errors, generated by
“devise_error_messages!” helper.
However, the errors of the “login” action are set via “flash[:alert]”.
So you probably are missing
flash[:alert] print out line in your layout file.

Refer to the documentations (README) the last paragraph in
“Configuring controllers” section.

You are getting validation errors not devise messages, validation errors
come from rails.

Tried flash[:alert] on the view. Still no luck.

Regarding Rick’s situation, I am not using customizations yet, it’s
Devise’s still default use.
Bad login message shows up. Errors on signup show up too.

On Wed, Sep 22, 2010 at 9:35 AM, radhames brito [email protected]
wrote:

add this

<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => “flash_#{name}” %>
<% end %>
it will loop the flash to see if there is any kind of message and create a
corresponding div

Thanks so much! That solved it!

and tundrax’s point to look at configuring controllers helped where it
says:

"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. "

(Sorry I hadn’t looked there since didn’t think it was related to that
section.)

In my application layout I had:

<%= flash[:notice] %>

but I did not have

<%= flash[:alert] %>

adding radhames’ loop, or the flash alert, solves it.

I take it the loop is better approach since it will work for any type
of flash message - notice or alert?


Rick R

no he meant you need to add the corresponding div , you see rails 2.x
scaffold adds

in the layout, but you need one div like that for each type of message
other
wise it wont appear.

add this

<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => “flash_#{name}” %>
<% end %>

it will loop the flash to see if there is any kind of message and create
a
corresponding div

I take it the loop is better approach since it will work for any type
of flash message - notice or alert?

yes the flash accepts anything you can do this in your controller

flash[:taco]= “i want taco”

and a corresponding tace div will be there too with its message

It’s still not working for me :frowning: My HAML code:
http://gist.github.com/592250

flash[:alert] is there. It does show the errors on a bad login, but it
doesn’t show actions when:

  • Trying to login when already logged in;
  • Trying to logout when not logged in at all.

surely devise has no errors for that, you can check the devise code and
see
if it does

On Wed, Sep 22, 2010 at 2:48 PM, José Mota [email protected] wrote:

It’s still not working for me :frowning: My HAML code: http://gist.github.com/592250

flash[:alert] is there. It does show the errors on a bad login, but it
doesn’t show actions when:

  • Trying to login when already logged in;
  • Trying to logout when not logged in at all.

Are you sure it’s supposed to?

Are you using the provided menu items that Devise gives you:

<%= render ‘devise/menu/registration_items’ %>
<%= render ‘devise/menu/login_items’ %>

You can generate those views if you want and look at them and you’ll
see you shouldn’t have the options you describe available under those
conditions.


Rick R

I talked to José Valim himself. So it seems Devise won’t tell if “you
are already logged in” or “you are not logged in”.

Thanks for the help guys!