# Problems getting flash to display

**URL:** <https://www.ruby-forum.com/t/problems-getting-flash-to-display/113991>\
**Category:** Rails\
**Created:** [September 6, 2007, 10:56pm UTC](https://www.ruby-forum.com/t/problems-getting-flash-to-display/113991 "2007-09-06T22:56:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bnab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bnab](https://www.ruby-forum.com/u/bnab)\
**Post date:** [September 6, 2007, 10:56pm UTC](https://www.ruby-forum.com/t/problems-getting-flash-to-display/113991/1 "2007-09-06T22:56:22Z")

</div>

I have a controller that looks exactly like the code below. My problem  
is that I can’t get the flash[:notice]'s to show up on the page.  
Interestingly though, I when I test this controller, I have tests that  
make it go down both of the unhappy paths (the  
ActiveRecord::RecordInvalid exception and ‘some\_boolean\_expression  
should’ve been true’) and these tests pass when ‘assert\_match’ on the  
flash…

assert\_match(/Error saving:/, flash[:notice])

and

assert\_match(/some\_boolean\_expression should’ve been true/,  
flash[:notice])

respectively

Any thoughts on what could possibly explain the fact I can’t see the  
flash in the browser?

TIA…

===== controller code =====

def do\_the\_action  
if (some\_boolean\_expression)  
begin  
model = ModelObject.new(:attribute1 =\> “1”, :attribute2 =\> “2”)  
model.save!

```
    path = "a/path"
    redirect_to(path)
  rescue ActiveRecord::RecordInvalid => error
    # findme: this flash notice doesn't seem to be showing up;

```

logging it for now  
@@log.error(“Error saving: #{error}”)  
flash[:notice] = “Error saving: #{error}”  
redirect\_to :action =\> “show”  
end  
else  
# findme: this flash notice doesn’t seem to be showing up; logging  
it for now  
@@log.error(“some\_boolean\_expression should’ve been true”)  
flash[:notice] = “some\_boolean\_expression should’ve been true”  
redirect\_to :action =\> “show”  
end  
end

---

<div class="post-metadata">

**Author:** ![bnab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bnab](https://www.ruby-forum.com/u/bnab)\
**Post date:** [September 6, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/problems-getting-flash-to-display/113991/2 "2007-09-06T23:46:36Z")

</div>

Bryan N. wrote:

> I have a controller that looks exactly like the code below. My problem  
> is that I can’t get the flash[:notice]'s to show up on the page.

> Any thoughts on what could possibly explain the fact I can’t see the  
> flash in the browser?

what do your views look like?  
the controller certainly looks like it’s setting the flash (and your  
tests verify that)  
so including somewhere in your “show.rhtml” the line “\<%= flash[:status]  
%\>” should definitely be showing up.

---

<div class="post-metadata">

**Author:** ![bnab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bnab](https://www.ruby-forum.com/u/bnab)\
**Post date:** [September 7, 2007, 12:47am UTC](https://www.ruby-forum.com/t/problems-getting-flash-to-display/113991/3 "2007-09-07T00:47:32Z")

</div>

Like you say, my view template has ‘\<%= flash[:notice] %\>’ in it. I’m  
using hobo’s dryml though instead of rhtml, so that may be contributing  
to the problem. I’ll check over on their list.

Thanks…

---

<div class="post-metadata">

**Author:** ![bnab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bnab](https://www.ruby-forum.com/u/bnab)\
**Post date:** [September 7, 2007, 6:55pm UTC](https://www.ruby-forum.com/t/problems-getting-flash-to-display/113991/4 "2007-09-07T18:55:21Z")

</div>

Hopefully this will help someone else. The problem was that the first  
line of the ‘show’ action that the ‘do\_the\_action’ action was  
redirecting to did this:

flash[:notice] = nil

It threw me off since the flash was being picked up in the test.
