My flash is not accessible anymore!

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

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

Frederick C. wrote:

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

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:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs