Problem with flash[:notice]

Hello!

I am having some problems with flash[:notice].

In fact, in my code, I use flash[:error] for showing errors messages
and flash[:notice] for showing other messages.

All flash errors are correctly displayed, however flash notices are
never displayed. The code is the same for both of them:

- on the controller I have for example:

if create_asset
     flash[:notice] = 'Asset was successfully created.'
else
     flash[:error] = 'There were some problems on the creation of the
asset.'
end

- then, on the view I have:

- if (flash[:notice])
  #noticebox
    = flash[:notice]
- elsif (flash[:error])
  #errorbox
    = flash[:error]

Did someone have the same problem? Could you help me?

Thank you,

Amagoia.

there is no reason that the flash display the notice but not the
error. maybe it's your div 'errorbox' isn't displayed. try this in
your page to check if flash have values :

- flash.each do |key,value|
  = key.to_s + '=>' + value.to_s
(i'm not sure about haml synthax)

you will see something like :
notice=>Asset was successfully created.
or
error=>There were some problems on the creation of the asset.

Thank you for your answer.

It seems that flash[:notice] has no values.

Because the div 'errorbox' is working fine. And when I try with your
code I have no value for the flash notices. However, I have no problem
with flash errors and warnings. Although I do the same way for errors,
warnings and notices, it seems that the problem is only with the
notices.

amagoia

Flash is kind of a hash table, the name of the keys (:notice, :error, ...) is not important to how it works, you can pass messages to the user with :foo instead of :notice.

You surely have a logic flaw somewhere. You know that flash[:key] evaluates to what you expect in the _next_ request right? Normally there's a redirection in between.

-- fxn

Thank you.

Yes I think I will change the key of the flash hash table. Instead of
using the key "notice" I will use another one.

amagoia.