Hi all For some reason I can''t access my flash object anymore! When putting <p style="color: green"><%= flash[:notice] %></p> 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 -- Posted via http://www.ruby-forum.com/.
On Apr 21, 6:56 pm, Joshua Muheim <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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> Thanks for help > Josh > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Apr 21, 6:56�pm, Joshua Muheim <rails-mailing-l...@andreas-s.net> > 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 ? > > Fredyes, it is within layouts/_flash.html.erb Is this a problem? -- Posted via http://www.ruby-forum.com/.
On Apr 21, 7:13 pm, Joshua Muheim <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Apr 21, 6:56 pm, Joshua Muheim <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > 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> -- > Posted viahttp://www.ruby-forum.com/.
> Yes. partials get a local variable named after them, in this case > flash, which is shadowing rails'' flash > > self.flash[:notice] > > should work. > > FredWow, thanks a lot for this information. :-) -- Posted via http://www.ruby-forum.com/.