# Problem with flash\[:notice\]

**URL:** <https://www.ruby-forum.com/t/problem-with-flash-notice/119721>\
**Category:** Rails\
**Created:** [November 9, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/problem-with-flash-notice/119721 "2007-11-09T15:48:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amagoia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@amagoia](https://www.ruby-forum.com/u/amagoia)\
**Post date:** [November 9, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/problem-with-flash-notice/119721/1 "2007-11-09T15:48:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amagoia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@amagoia](https://www.ruby-forum.com/u/amagoia)\
**Post date:** [November 9, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/problem-with-flash-notice/119721/2 "2007-11-09T17:51:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amagoia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@amagoia](https://www.ruby-forum.com/u/amagoia)\
**Post date:** [November 12, 2007, 9:58am UTC](https://www.ruby-forum.com/t/problem-with-flash-notice/119721/3 "2007-11-12T09:58:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amagoia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@amagoia](https://www.ruby-forum.com/u/amagoia)\
**Post date:** [November 12, 2007, 1:09pm UTC](https://www.ruby-forum.com/t/problem-with-flash-notice/119721/4 "2007-11-12T13:09:20Z")

</div>

On Nov 12, 2007, at 9:57 AM, amagoia wrote:

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

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

---

<div class="post-metadata">

**Author:** ![amagoia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@amagoia](https://www.ruby-forum.com/u/amagoia)\
**Post date:** [November 12, 2007, 1:34pm UTC](https://www.ruby-forum.com/t/problem-with-flash-notice/119721/5 "2007-11-12T13:34:31Z")

</div>

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.
