# Flash message doesn't show up

**URL:** <https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673>\
**Category:** Rails\
**Created:** [August 21, 2010, 7:35pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673 "2010-08-21T19:35:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 21, 2010, 7:35pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/1 "2010-08-21T19:35:13Z")

</div>

In the controller method I have the following:

def create  
@adv = Adv.new(params[:adv])  
@adv.save  
flash[:notice] = “Advertisement successfully created”  
redirect\_to “/advs/#{@adv.id}”  
end

When I create a new “Adv”, I DON’T get the message: “Advertisement  
successfully created”

Why is that? What am I missing?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 21, 2010, 9:51pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/2 "2010-08-21T21:51:09Z")

</div>

On 21 August 2010 18:35, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In the controller method I have the following:
> 
> def create  
> @adv = Adv.new(params[:adv])  
> @adv.save  
> flash[:notice] = “Advertisement successfully created”  
> redirect\_to “/advs/#{@adv.id}”

The code here is setting up the flash but you have to have code in the  
view to display it. What have you got in the view that you are showing  
after the redirect?

Colin

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 22, 2010, 10:09am UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/3 "2010-08-22T10:09:40Z")

</div>

In View have you added \<%= flash[:notice] %\>  
and \<%= javascript\_include\_tag :defaults %\>

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 22, 2010, 3:26pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/4 "2010-08-22T15:26:35Z")

</div>

Thanks a lot everyone.

You are correct:

Yes, I have added “\<%= flash[:notice] %\>” in “application.html.erb”

I just want to ask, how can we make that notice with a different color  
and background? Should we do this manually by HTML for example?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 22, 2010, 4:21pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/5 "2010-08-22T16:21:19Z")

</div>

Bill W. wrote:

> On Sun, Aug 22, 2010 at 8:26 AM, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I just want to ask, how can we make that notice with a different color  
> > and background? Should we do this manually by HTML for example?
> 
> Change the values in the selector in application.css
> 
> HTH,  
> Bill

I made some changes in “application.html.erb” as follows:

\<%= flash[:notice] %\>

And it did what I was looking for.

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 22, 2010, 4:35pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/6 "2010-08-22T16:35:24Z")

</div>

On Sun, Aug 22, 2010 at 9:21 AM, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I made some changes in “application.html.erb” as follows:
> 
> \<%= flash[:notice] %\>
> 
> And it did what I was looking for.

Inline styling will certainly work but it has very much fallen out of  
favor. You will do yourself a favor, professional reputation-wise, by  
learning to use css selectors.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 22, 2010, 4:19pm UTC](https://www.ruby-forum.com/t/flash-message-doesnt-show-up/193673/7 "2010-08-22T16:19:35Z")

</div>

On Sun, Aug 22, 2010 at 8:26 AM, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I just want to ask, how can we make that notice with a different color  
> and background? Should we do this manually by HTML for example?

Change the values in the selector in application.css

HTH,  
Bill
