My flash is not accessible anymore!


#1

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


#2

On Apr 21, 6:56 pm, Joshua M. 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


#3

Frederick C. wrote:

On Apr 21, 6:56�pm, Joshua M. 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?


#4

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


#5

On Apr 21, 7:13 pm, Joshua M. 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