# Flash error & fade away

**URL:** <https://www.ruby-forum.com/t/flash-error-fade-away/185710>\
**Category:** Rails\
**Created:** [March 24, 2010, 10:43pm UTC](https://www.ruby-forum.com/t/flash-error-fade-away/185710 "2010-03-24T22:43:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [March 24, 2010, 10:43pm UTC](https://www.ruby-forum.com/t/flash-error-fade-away/185710/1 "2010-03-24T22:43:18Z")

</div>

this is my current code:

#notice {  
border: solid 1px #99cc99;  
background-color: #e2f9e3;  
color: #006600;  
padding: 5px;  
margin-bottom: 5px;  
}

#notice.error {  
border-color: #e2f9e3;  
background-color: #eeaaaa;  
color: #cc0000;  
}

\<% flash.each do |key, msg| %\>  
\<%= content\_tag :div, flash[:error] || flash[:notice], :id =\>  
‘notice’,  
:class =\> (‘error’ if flash[:error]) %\>  
\<% content\_tag :script, :type =\> “text/javascript” do %\>  
$(’\<%= key %\>’).style.display = ‘none’;  
new Effect.Appear(’\<%= key %\>’, {duration: 3});  
\<% end %\>

\<% content\_tag :script, :type =\> “text/javascript” do %\>  
setTimeout(“new Effect.Fade(’\<%= key %\>’);”, 10000);  
\<% end %\>  
\<% end %\>

but how can i achieve to css the rails standard way of showing errors  
liek  
that one:  
1 error prohibited this comment from being saved

There were problems with the following fields:

- Title can’t be blank

only if i return something like that:  
flash[:error] = ‘Error’

it actually shows up in “my” div.

hope u guys know what i mean 😉

thx

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [March 25, 2010, 7:27pm UTC](https://www.ruby-forum.com/t/flash-error-fade-away/185710/2 "2010-03-25T19:27:17Z")

</div>

Hey,

Not quite understood â€“ could you explain further?

Thanks,  
/Lasse

2010/3/24 tom [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [March 25, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/flash-error-fade-away/185710/3 "2010-03-25T21:23:09Z")

</div>

hi,ok let me try:

i want the standard rails (error)messages like this one:  
1 error prohibited this comment from being saved

There were problems with the following fields:

- Title can’t be blank

to fade away.  
so not sure how to do that…

thx

---

<div class="post-metadata">

**Author:** ![tomtt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@tomtt](https://www.ruby-forum.com/u/tomtt)\
**Post date:** [March 25, 2010, 10:07pm UTC](https://www.ruby-forum.com/t/flash-error-fade-away/185710/4 "2010-03-25T22:07:03Z")

</div>

Ok â€“ you could easily do this by fading the div with  
id=“errorExplanation”,  
like this:

$(‘errorExplanation’).fade();

Would this do it?

/Lasse

2010/3/25 tom [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
