# My flash is not accessible anymore!

**URL:** <https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090>\
**Category:** Rails\
**Created:** [April 21, 2009, 7:56pm UTC](https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090 "2009-04-21T19:56:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 7:56pm UTC](https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090/1 "2009-04-21T19:56:34Z")

</div>

Hi all

For some reason I can’t access my flash object anymore! When putting

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

in my view, I get the following error:

You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]

Extracted source (around line #1):

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

What the heck is the problem here? I can’t remember doing anything that  
could have caused this…?

Thanks for help  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 8:12pm UTC](https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090/2 "2009-04-21T20:12:54Z")

</div>

On Apr 21, 6:56 pm, Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Extracted source (around line #1):
> 
> 1: \<%= flash[:notice] %\>
> 
> What the heck is the problem here? I can’t remember doing anything that  
> could have caused this…?

is this in a partial or view called flash ?

Fred

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 8:13pm UTC](https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090/3 "2009-04-21T20:13:55Z")

</div>

Frederick C. wrote:

> On Apr 21, 6:56ï¿½pm, Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Extracted source (around line #1):
> > 
> > 1: \<%= flash[:notice] %\>
> > 
> > What the heck is the problem here? I can’t remember doing anything that  
> > could have caused this…?
> 
> is this in a partial or view called flash ?
> 
> Fred

yes, it is within layouts/\_flash.html.erb

Is this a problem?

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090/4 "2009-04-21T21:25:27Z")

</div>

> Yes. partials get a local variable named after them, in this case  
> flash, which is shadowing rails’ flash
> 
> self.flash[:notice]
> 
> should work.
> 
> Fred

Wow, thanks a lot for this information. 🙂

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [April 21, 2009, 9:23pm UTC](https://www.ruby-forum.com/t/my-flash-is-not-accessible-anymore/166090/5 "2009-04-21T21:23:27Z")

</div>

On Apr 21, 7:13 pm, Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > is this in a partial or view called flash ?
> 
> > Fred
> 
> yes, it is within layouts/\_flash.html.erb
> 
> Is this a problem?

Yes. partials get a local variable named after them, in this case  
flash, which is shadowing rails’ flash

self.flash[:notice]

should work.

Fred
