can anybody think of a reason that flash[:notice] would not work ? I set if @location.save flash[:notice] = ''Location was successfully created.'' redirect_to :action => ''list_locations'' else redirect_to :action => ''list_locations'' end then in my layout that list_locations.rhtml uses i put: <% if @flash[:notice] -%> <div id="notice"> MESSAGE: <%=h @flash[:notice] %> </div> <% end %> however nothing is showing up.. any ideas ? thanks adam
seems this is only available in the view, not in the layout.. is this possible ? On Aug 25, 2005, at 3:28 PM, Adam Denenberg wrote:> can anybody think of a reason that flash[:notice] would not work ? > > I set > > if @location.save > flash[:notice] = ''Location was successfully created.'' > redirect_to :action => ''list_locations'' > else > redirect_to :action => ''list_locations'' > end > > then in my layout that list_locations.rhtml uses i put: > > <% if @flash[:notice] -%> > <div id="notice"> > MESSAGE: <%=h @flash[:notice] %> > </div> > <% end %> > > however nothing is showing up.. any ideas ? > > thanks > adam > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Adam, Are you sure the location object is being saved (since when it is not saved, flash isn''t set)? You can test using @location.save! which will raise a RecordInvalid exception if the object can''t be saved. - Derek On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote:> can anybody think of a reason that flash[:notice] would not work ? > > I set > > if @location.save > flash[:notice] = ''Location was successfully created.'' > redirect_to :action => ''list_locations'' > else > redirect_to :action => ''list_locations'' > end > > then in my layout that list_locations.rhtml uses i put: > > <% if @flash[:notice] -%> > <div id="notice"> > MESSAGE: <%=h @flash[:notice] %> > </div> > <% end %> > > however nothing is showing up.. any ideas ? > > thanks > adam > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Derek Haynes HighGroove Studios - http://www.highgroove.com Keeping it Simple. 404.593.4879
yes b/c it shows up in my list, and also if i move the flash[:notice] to the view, and out of the layout it works ok. I cant figure out why it would work in a view, and not in a layout. any ideas ? thanks adam On Aug 25, 2005, at 3:36 PM, Derek Haynes wrote:> Adam, > > Are you sure the location object is being saved (since when it is not > saved, flash isn''t set)? You can test using @location.save! which will > raise a RecordInvalid exception if the object can''t be saved. > > - Derek > > On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: > >> can anybody think of a reason that flash[:notice] would not work ? >> >> I set >> >> if @location.save >> flash[:notice] = ''Location was successfully created.'' >> redirect_to :action => ''list_locations'' >> else >> redirect_to :action => ''list_locations'' >> end >> >> then in my layout that list_locations.rhtml uses i put: >> >> <% if @flash[:notice] -%> >> <div id="notice"> >> MESSAGE: <%=h @flash[:notice] %> >> </div> >> <% end %> >> >> however nothing is showing up.. any ideas ? >> >> thanks >> adam >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > > -- > Derek Haynes > HighGroove Studios - http://www.highgroove.com > Keeping it Simple. > 404.593.4879 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
I don''t know the answer to your problem, but I do know that I am indeed using the flash-feature from within my layout file. ------------------------------------------------------------------------ /*Ronny Hanssen*/ Adam Denenberg wrote:> yes b/c it shows up in my list, and also if i move the flash[:notice] > to the view, and out of the layout it works ok. I cant figure out why > it would work in a view, and not in a layout. any ideas ? > > thanks > adam > > On Aug 25, 2005, at 3:36 PM, Derek Haynes wrote: > >> Adam, >> >> Are you sure the location object is being saved (since when it is not >> saved, flash isn''t set)? You can test using @location.save! which will >> raise a RecordInvalid exception if the object can''t be saved. >> >> - Derek >> >> On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: >> >>> can anybody think of a reason that flash[:notice] would not work ? >>> >>> I set >>> >>> if @location.save >>> flash[:notice] = ''Location was successfully created.'' >>> redirect_to :action => ''list_locations'' >>> else >>> redirect_to :action => ''list_locations'' >>> end >>> >>> then in my layout that list_locations.rhtml uses i put: >>> >>> <% if @flash[:notice] -%> >>> <div id="notice"> >>> MESSAGE: <%=h @flash[:notice] %> >>> </div> >>> <% end %> >>> >>> however nothing is showing up.. any ideas ? >>> >>> thanks >>> adam >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >> >> >> -- >> Derek Haynes >> HighGroove Studios - http://www.highgroove.com >> Keeping it Simple. >> 404.593.4879 >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
BTW: It just struck me. looking at your code that you refer to @flash[] in the rhtml file. Shouldn''t that be flash[], without the at-sign? ------------------------------------------------------------------------ /*Ronny Hanssen*/ Adam Denenberg wrote:> yes b/c it shows up in my list, and also if i move the flash[:notice] > to the view, and out of the layout it works ok. I cant figure out why > it would work in a view, and not in a layout. any ideas ? > > thanks > adam > > On Aug 25, 2005, at 3:36 PM, Derek Haynes wrote: > >> Adam, >> >> Are you sure the location object is being saved (since when it is not >> saved, flash isn''t set)? You can test using @location.save! which will >> raise a RecordInvalid exception if the object can''t be saved. >> >> - Derek >> >> On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: >> >>> can anybody think of a reason that flash[:notice] would not work ? >>> >>> I set >>> >>> if @location.save >>> flash[:notice] = ''Location was successfully created.'' >>> redirect_to :action => ''list_locations'' >>> else >>> redirect_to :action => ''list_locations'' >>> end >>> >>> then in my layout that list_locations.rhtml uses i put: >>> >>> <% if @flash[:notice] -%> >>> <div id="notice"> >>> MESSAGE: <%=h @flash[:notice] %> >>> </div> >>> <% end %> >>> >>> however nothing is showing up.. any ideas ? >>> >>> thanks >>> adam >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >> >> >> -- >> Derek Haynes >> HighGroove Studios - http://www.highgroove.com >> Keeping it Simple. >> 404.593.4879 >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
hm good find. However this does not work either.. What would effect not seeing it in a layout, but seeing it in a view? Wierd... On Aug 25, 2005, at 4:13 PM, Ronny Hanssen wrote:> BTW: It just struck me. looking at your code that you refer to > @flash[] > in the rhtml file. Shouldn''t that be flash[], without the at-sign? > > ---------------------------------------------------------------------- > -- > /*Ronny Hanssen*/ > > > Adam Denenberg wrote: > >> yes b/c it shows up in my list, and also if i move the flash[:notice] >> to the view, and out of the layout it works ok. I cant figure >> out why >> it would work in a view, and not in a layout. any ideas ? >> >> thanks >> adam >> >> On Aug 25, 2005, at 3:36 PM, Derek Haynes wrote: >> >> >>> Adam, >>> >>> Are you sure the location object is being saved (since when it is >>> not >>> saved, flash isn''t set)? You can test using @location.save! which >>> will >>> raise a RecordInvalid exception if the object can''t be saved. >>> >>> - Derek >>> >>> On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: >>> >>> >>>> can anybody think of a reason that flash[:notice] would not work ? >>>> >>>> I set >>>> >>>> if @location.save >>>> flash[:notice] = ''Location was successfully created.'' >>>> redirect_to :action => ''list_locations'' >>>> else >>>> redirect_to :action => ''list_locations'' >>>> end >>>> >>>> then in my layout that list_locations.rhtml uses i put: >>>> >>>> <% if @flash[:notice] -%> >>>> <div id="notice"> >>>> MESSAGE: <%=h @flash[:notice] %> >>>> </div> >>>> <% end %> >>>> >>>> however nothing is showing up.. any ideas ? >>>> >>>> thanks >>>> adam >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>>> >>> >>> >>> -- >>> Derek Haynes >>> HighGroove Studios - http://www.highgroove.com >>> Keeping it Simple. >>> 404.593.4879 >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Are you seeing "MESSAGE: " at all? (i.e. not the flash[] contents, but the prepended text) If not, try this: <%= "<div id=''notice''>MESSAGE: #{h(flash[:notice])}</div>" if flash[:notice] %> Notice there are no @flash anywhere and we''re not suppressing output on the if (via -%>) On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote:> hm good find. However this does not work either.. What would effect > not seeing it in a layout, but seeing it in a view? Wierd... > > > On Aug 25, 2005, at 4:13 PM, Ronny Hanssen wrote: > > > BTW: It just struck me. looking at your code that you refer to > > @flash[] > > in the rhtml file. Shouldn''t that be flash[], without the at-sign? > > > > ---------------------------------------------------------------------- > > -- > > /*Ronny Hanssen*/ > > > > > > Adam Denenberg wrote: > > > >> yes b/c it shows up in my list, and also if i move the flash[:notice] > >> to the view, and out of the layout it works ok. I cant figure > >> out why > >> it would work in a view, and not in a layout. any ideas ? > >> > >> thanks > >> adam > >> > >> On Aug 25, 2005, at 3:36 PM, Derek Haynes wrote: > >> > >> > >>> Adam, > >>> > >>> Are you sure the location object is being saved (since when it is > >>> not > >>> saved, flash isn''t set)? You can test using @location.save! which > >>> will > >>> raise a RecordInvalid exception if the object can''t be saved. > >>> > >>> - Derek > >>> > >>> On 8/25/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: > >>> > >>> > >>>> can anybody think of a reason that flash[:notice] would not work ? > >>>> > >>>> I set > >>>> > >>>> if @location.save > >>>> flash[:notice] = ''Location was successfully created.'' > >>>> redirect_to :action => ''list_locations'' > >>>> else > >>>> redirect_to :action => ''list_locations'' > >>>> end > >>>> > >>>> then in my layout that list_locations.rhtml uses i put: > >>>> > >>>> <% if @flash[:notice] -%> > >>>> <div id="notice"> > >>>> MESSAGE: <%=h @flash[:notice] %> > >>>> </div> > >>>> <% end %> > >>>> > >>>> however nothing is showing up.. any ideas ? > >>>> > >>>> thanks > >>>> adam > >>>> > >>>> _______________________________________________ > >>>> Rails mailing list > >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>> > >>>> > >>>> > >>> > >>> > >>> -- > >>> Derek Haynes > >>> HighGroove Studios - http://www.highgroove.com > >>> Keeping it Simple. > >>> 404.593.4879 > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > >>> > >>> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Brock Weaver [OBC]Technique
Agile Dev, page 88, shows how to put a flash[] in a layout. Minor edits here for clarity: "So, the logging worked. But the flash message didn’t appear on the user’s browser. That’s because we didn’t display it. We’ll need to add something to the layout to tell it to display flash messages if they exist. The following rhtml code checks for a notice-level flash message and creates a new <div> containing it if necessary. <% if @flash[:notice] -%> <div id="notice"><%= @flash[:notice] %></div> <% end -%>" Note that the key is checking @flash, not some other variable which may be local to the view, but not the layout (is that really correct?).> yes b/c it shows up in my list, and also if i move the flash[:notice] > to the view, and out of the layout it works ok. I cant figure out > why it would work in a view, and not in a layout. any ideas ?>>>> Are you sure the location object is being saved (since when it is >>> not saved, flash isn''t set)? You can test using @location.save! >>> which will raise a RecordInvalid exception if the object can''t be >>> saved.
i am seeing "MESSAGE" which is why i stuck it in there. Just seems like the layout wont grab the @flash variable, not sure why. I have tried @flash[:notice], flash[:notice].. removed and put back <div id=notice> tags.. nothing... stumped. adam On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote:> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor > edits here for clarity: > > "So, the logging worked. But the flash message didn’t appear on the > user’s browser. That’s because we didn’t display it. We’ll need to > add something to the layout to tell it to display flash messages if > they exist. The following rhtml code checks for a notice-level > flash message and creates a new <div> containing it if necessary. > > <% if @flash[:notice] -%> > <div id="notice"><%= @flash[:notice] %></div> > <% end -%>" > > Note that the key is checking @flash, not some other variable which > may be local to the view, but not the layout (is that really > correct?). > > >> yes b/c it shows up in my list, and also if i move the flash[:notice] >> to the view, and out of the layout it works ok. I cant figure out >> why it would work in a view, and not in a layout. any ideas ? >> > > > >>>> Are you sure the location object is being saved (since when it is >>>> not saved, flash isn''t set)? You can test using @location.save! >>>> which will raise a RecordInvalid exception if the object can''t be >>>> saved. >>>> > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means @flash[:notice] is evaluating to false for some bizarre reason. i even tried <% for f in @flash %> FLASH VAL: <%= f %> <% end %> nothing.. still coming up fine in the view however. adam On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote:> i am seeing "MESSAGE" which is why i stuck it in there. Just seems > like the layout wont grab the @flash variable, not sure why. > > I have tried @flash[:notice], flash[:notice].. removed and put back > <div id=notice> tags.. nothing... > > stumped. > > adam > > On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: > > >> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor >> edits here for clarity: >> >> "So, the logging worked. But the flash message didn’t appear on >> the user’s browser. That’s because we didn’t display it. We’ll >> need to add something to the layout to tell it to display flash >> messages if they exist. The following rhtml code checks for a >> notice-level flash message and creates a new <div> containing it >> if necessary. >> >> <% if @flash[:notice] -%> >> <div id="notice"><%= @flash[:notice] %></div> >> <% end -%>" >> >> Note that the key is checking @flash, not some other variable >> which may be local to the view, but not the layout (is that really >> correct?). >> >> >> >>> yes b/c it shows up in my list, and also if i move the flash >>> [:notice] >>> to the view, and out of the layout it works ok. I cant figure out >>> why it would work in a view, and not in a layout. any ideas ? >>> >>> >> > >> >> >>>>> Are you sure the location object is being saved (since when it is >>>>> not saved, flash isn''t set)? You can test using @location.save! >>>>> which will raise a RecordInvalid exception if the object can''t be >>>>> saved. >>>>> >>>>> >> >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
You''ve also made sure that you''ve been using the flash[:notice] without the @-sign both places? Also in the if test? I can''t spot any other problem. In my code I am using it without the @-sign. And it works. In my controller-action I have: def edit @article = Article.find(params[:id]) if params[:article] and @article.update_attributes(params[:article]) flash[:notice] = ''Article was successfully updated.'' render :action => ''show'' end end And in my layout file I am using: <% if flash[:notice] %> <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> <% flash[:notice] = nil %> <% end %> That works at least. I''m not sure if I''m supposed to nil the flash[:notice] after use. I think I added it because the message seemed to be stuck longer than it should, somehow. ------------------------------------------------------------------------ /*Ronny Hanssen*/ Adam Denenberg wrote:> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means > @flash[:notice] is evaluating to false for some bizarre reason. > > i even tried > > <% for f in @flash %> > FLASH VAL: <%= f %> > <% end %> > > nothing.. still coming up fine in the view however. > > adam > > On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: > >> i am seeing "MESSAGE" which is why i stuck it in there. Just seems >> like the layout wont grab the @flash variable, not sure why. >> >> I have tried @flash[:notice], flash[:notice].. removed and put back >> <div id=notice> tags.. nothing... >> >> stumped. >> >> adam >> >> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: >> >> >>> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor >>> edits here for clarity: >>> >>> "So, the logging worked. But the flash message didn’t appear on the >>> user’s browser. That’s because we didn’t display it. We’ll need to >>> add something to the layout to tell it to display flash messages if >>> they exist. The following rhtml code checks for a notice-level flash >>> message and creates a new <div> containing it if necessary. >>> >>> <% if @flash[:notice] -%> >>> <div id="notice"><%= @flash[:notice] %></div> >>> <% end -%>" >>> >>> Note that the key is checking @flash, not some other variable which >>> may be local to the view, but not the layout (is that really correct?). >>> >>> >>> >>>> yes b/c it shows up in my list, and also if i move the flash [:notice] >>>> to the view, and out of the layout it works ok. I cant figure out >>>> why it would work in a view, and not in a layout. any ideas ? >>>> >>>> >>> > >>> >>> >>>>>> Are you sure the location object is being saved (since when it is >>>>>> not saved, flash isn''t set)? You can test using @location.save! >>>>>> which will raise a RecordInvalid exception if the object can''t be >>>>>> saved. >>>>>> >>>>>> >>> >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I had the same problem. I didn''t do anything "special" to solve it, just the folling: 1) In my controller, I always use the syntax: flash["notice"] = "this is my flash text" 2) In my view file, I always check if @flash["notice"] 3) If I see a problem, I restart the webrick server in mode "-e production", and I check that in this mode no problem occurs. I believe points 1 and 2 are not really useful, my opinion is that only point 3) is relevant. . On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote:> > You''ve also made sure that you''ve been using the flash[:notice] without > the @-sign both places? Also in the if test? > > I can''t spot any other problem. In my code I am using it without the > @-sign. And it works. In my controller-action I have: > > def edit > @article = Article.find(params[:id]) > if params[:article] and @article.update_attributes(params[:article]) > flash[:notice] = ''Article was successfully updated.'' > render :action => ''show'' > end > end > > And in my layout file I am using: > > <% if flash[:notice] %> > <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> > <% flash[:notice] = nil %> > <% end %> > > That works at least. I''m not sure if I''m supposed to nil the > flash[:notice] after use. I think I added it because the message seemed > to be stuck longer than it should, somehow. > > ------------------------------------------------------------------------ > /*Ronny Hanssen*/ > > > Adam Denenberg wrote: > > sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means > > @flash[:notice] is evaluating to false for some bizarre reason. > > > > i even tried > > > > <% for f in @flash %> > > FLASH VAL: <%= f %> > > <% end %> > > > > nothing.. still coming up fine in the view however. > > > > adam > > > > On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: > > > >> i am seeing "MESSAGE" which is why i stuck it in there. Just seems > >> like the layout wont grab the @flash variable, not sure why. > >> > >> I have tried @flash[:notice], flash[:notice].. removed and put back > >> <div id=notice> tags.. nothing... > >> > >> stumped. > >> > >> adam > >> > >> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: > >> > >> > >>> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor > >>> edits here for clarity: > >>> > >>> "So, the logging worked. But the flash message didn''t appear on the > >>> user''s browser. That''s because we didn''t display it. We''ll need to > >>> add something to the layout to tell it to display flash messages if > >>> they exist. The following rhtml code checks for a notice-level flash > >>> message and creates a new <div> containing it if necessary. > >>> > >>> <% if @flash[:notice] -%> > >>> <div id="notice"><%= @flash[:notice] %></div> > >>> <% end -%>" > >>> > >>> Note that the key is checking @flash, not some other variable which > >>> may be local to the view, but not the layout (is that really > correct?). > >>> > >>> > >>> > >>>> yes b/c it shows up in my list, and also if i move the flash > [:notice] > >>>> to the view, and out of the layout it works ok. I cant figure out > >>>> why it would work in a view, and not in a layout. any ideas ? > >>>> > >>>> > >>> > > >>> > >>> > >>>>>> Are you sure the location object is being saved (since when it is > >>>>>> not saved, flash isn''t set)? You can test using @location.save! > >>>>>> which will raise a RecordInvalid exception if the object can''t be > >>>>>> saved. > >>>>>> > >>>>>> > >>> > >>> > >>> > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > >>> > >>> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hello, Be careful with the cache, look at your public folder for cached html pages. I had this problem too ;) 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> I had the same problem. I didn''t do anything "special" to solve it, just the > folling: > 1) In my controller, I always use the syntax: flash["notice"] = "this is my > flash text" > 2) In my view file, I always check if @flash["notice"] > 3) If I see a problem, I restart the webrick server in mode "-e > production", and I check that in this mode no problem occurs. > > I believe points 1 and 2 are not really useful, my opinion is that only > point 3) is relevant. > . > > > On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: > > You''ve also made sure that you''ve been using the flash[:notice] without > > the @-sign both places? Also in the if test? > > > > I can''t spot any other problem. In my code I am using it without the > > @-sign. And it works. In my controller-action I have: > > > > def edit > > @article = Article.find(params[:id]) > > if params[:article] and > @article.update_attributes(params[:article]) > > flash[:notice] = ''Article was successfully updated.'' > > render :action => ''show'' > > end > > end > > > > And in my layout file I am using: > > > > <% if flash[:notice] %> > > <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> > > <% flash[:notice] = nil %> > > <% end %> > > > > That works at least. I''m not sure if I''m supposed to nil the > > flash[:notice] after use. I think I added it because the message seemed > > to be stuck longer than it should, somehow. > > > > > ------------------------------------------------------------------------ > > /*Ronny Hanssen*/ > > > > > > Adam Denenberg wrote: > > > sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means > > > @flash[:notice] is evaluating to false for some bizarre reason. > > > > > > i even tried > > > > > > <% for f in @flash %> > > > FLASH VAL: <%= f %> > > > <% end %> > > > > > > nothing.. still coming up fine in the view however. > > > > > > adam > > > > > > On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: > > > > > >> i am seeing "MESSAGE" which is why i stuck it in there. Just seems > > >> like the layout wont grab the @flash variable, not sure why. > > >> > > >> I have tried @flash[:notice], flash[:notice].. removed and put back > > >> <div id=notice> tags.. nothing... > > >> > > >> stumped. > > >> > > >> adam > > >> > > >> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: > > >> > > >> > > >>> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor > > >>> edits here for clarity: > > >>> > > >>> "So, the logging worked. But the flash message didn''t appear on the > > >>> user''s browser. That''s because we didn''t display it. We''ll need to > > >>> add something to the layout to tell it to display flash messages if > > >>> they exist. The following rhtml code checks for a notice-level flash > > >>> message and creates a new <div> containing it if necessary. > > >>> > > >>> <% if @flash[:notice] -%> > > >>> <div id="notice"><%= @flash[:notice] %></div> > > >>> <% end -%>" > > >>> > > >>> Note that the key is checking @flash, not some other variable which > > >>> may be local to the view, but not the layout (is that really > correct?). > > >>> > > >>> > > >>> > > >>>> yes b/c it shows up in my list, and also if i move the flash > [:notice] > > >>>> to the view, and out of the layout it works ok. I cant figure out > > >>>> why it would work in a view, and not in a layout. any ideas ? > > >>>> > > >>>> > > >>> > > > >>> > > >>> > > >>>>>> Are you sure the location object is being saved (since when it is > > >>>>>> not saved, flash isn''t set)? You can test using @location.save! > > >>>>>> which will raise a RecordInvalid exception if the object can''t be > > >>>>>> saved. > > >>>>>> > > >>>>>> > > >>> > > >>> > > >>> > > >>> _______________________________________________ > > >>> Rails mailing list > > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>> > > >>> > > >>> > > >> > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > >> > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- ------------------------------------------ David Siñuela Pastor (siu) http://www.4coders.com E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org
tried all of these with the same results. Production / dev, quotes, no quotes.. nothing seems to work. On Aug 26, 2005, at 10:05 AM, David Siñuela wrote:> Hello, > > Be careful with the cache, look at your public folder for cached > html pages.. > > I had this problem too ;) > > 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> I had the same problem. I didn''t do anything "special" to solve >> it, just the >> folling: >> 1) In my controller, I always use the syntax: flash["notice"] = >> "this is my >> flash text" >> 2) In my view file, I always check if @flash["notice"] >> 3) If I see a problem, I restart the webrick server in mode "-e >> production", and I check that in this mode no problem occurs. >> >> I believe points 1 and 2 are not really useful, my opinion is >> that only >> point 3) is relevant. >> . >> >> >> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: >> >>> You''ve also made sure that you''ve been using the flash[:notice] >>> without >>> the @-sign both places? Also in the if test? >>> >>> I can''t spot any other problem. In my code I am using it without the >>> @-sign. And it works. In my controller-action I have: >>> >>> def edit >>> @article = Article.find(params[:id]) >>> if params[:article] and >>> >> @article.update_attributes(params[:article]) >> >>> flash[:notice] = ''Article was successfully updated.'' >>> render :action => ''show'' >>> end >>> end >>> >>> And in my layout file I am using: >>> >>> <% if flash[:notice] %> >>> <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> >>> <% flash[:notice] = nil %> >>> <% end %> >>> >>> That works at least. I''m not sure if I''m supposed to nil the >>> flash[:notice] after use. I think I added it because the message >>> seemed >>> to be stuck longer than it should, somehow. >>> >>> >>> >> --------------------------------------------------------------------- >> --- >> >>> /*Ronny Hanssen*/ >>> >>> >>> Adam Denenberg wrote: >>> >>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means >>>> @flash[:notice] is evaluating to false for some bizarre reason. >>>> >>>> i even tried >>>> >>>> <% for f in @flash %> >>>> FLASH VAL: <%= f %> >>>> <% end %> >>>> >>>> nothing.. still coming up fine in the view however. >>>> >>>> adam >>>> >>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: >>>> >>>> >>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just seems >>>>> like the layout wont grab the @flash variable, not sure why. >>>>> >>>>> I have tried @flash[:notice], flash[:notice].. removed and put >>>>> back >>>>> <div id=notice> tags.. nothing... >>>>> >>>>> stumped. >>>>> >>>>> adam >>>>> >>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: >>>>> >>>>> >>>>> >>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor >>>>>> edits here for clarity: >>>>>> >>>>>> "So, the logging worked. But the flash message didn''t appear >>>>>> on the >>>>>> user''s browser. That''s because we didn''t display it. We''ll >>>>>> need to >>>>>> add something to the layout to tell it to display flash >>>>>> messages if >>>>>> they exist. The following rhtml code checks for a notice- >>>>>> level flash >>>>>> message and creates a new <div> containing it if necessary. >>>>>> >>>>>> <% if @flash[:notice] -%> >>>>>> <div id="notice"><%= @flash[:notice] %></div> >>>>>> <% end -%>" >>>>>> >>>>>> Note that the key is checking @flash, not some other variable >>>>>> which >>>>>> may be local to the view, but not the layout (is that really >>>>>> >> correct?). >> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>> yes b/c it shows up in my list, and also if i move the flash >>>>>>> >> [:notice] >> >>>>>>> to the view, and out of the layout it works ok. I cant >>>>>>> figure out >>>>>>> why it would work in a view, and not in a layout. any ideas ? >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>>>>> Are you sure the location object is being saved (since when >>>>>>>>> it is >>>>>>>>> not saved, flash isn''t set)? You can test using >>>>>>>>> @location.save! >>>>>>>>> which will raise a RecordInvalid exception if the object >>>>>>>>> can''t be >>>>>>>>> saved. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Rails mailing list >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> >> > > > -- > ------------------------------------------ > David Siñuela Pastor (siu) > http://www.4coders.com > E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
You''re not accidentally doing a double-redirect are you? I mean, when you: flash[:notice] = ''Location was successfully created.'' redirect_to :action => ''list_locations'' Does your list_actions method redirect? The flash[:notice] is removed from the session automatically after 1 round trip (or zero if you use flash_now). You are performing one redirect in the code above, and if the code in that function performs a redirect, your flash[:notice] will die off on the first one. On 8/26/05, David Siñuela <siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > Be careful with the cache, look at your public folder for cached html pages. > > I had this problem too ;) > > 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > I had the same problem. I didn''t do anything "special" to solve it, just the > > folling: > > 1) In my controller, I always use the syntax: flash["notice"] = "this is my > > flash text" > > 2) In my view file, I always check if @flash["notice"] > > 3) If I see a problem, I restart the webrick server in mode "-e > > production", and I check that in this mode no problem occurs. > > > > I believe points 1 and 2 are not really useful, my opinion is that only > > point 3) is relevant. > > . > > > > > > On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: > > > You''ve also made sure that you''ve been using the flash[:notice] without > > > the @-sign both places? Also in the if test? > > > > > > I can''t spot any other problem. In my code I am using it without the > > > @-sign. And it works. In my controller-action I have: > > > > > > def edit > > > @article = Article.find(params[:id]) > > > if params[:article] and > > @article.update_attributes(params[:article]) > > > flash[:notice] = ''Article was successfully updated.'' > > > render :action => ''show'' > > > end > > > end > > > > > > And in my layout file I am using: > > > > > > <% if flash[:notice] %> > > > <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> > > > <% flash[:notice] = nil %> > > > <% end %> > > > > > > That works at least. I''m not sure if I''m supposed to nil the > > > flash[:notice] after use. I think I added it because the message seemed > > > to be stuck longer than it should, somehow. > > > > > > > > ------------------------------------------------------------------------ > > > /*Ronny Hanssen*/ > > > > > > > > > Adam Denenberg wrote: > > > > sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means > > > > @flash[:notice] is evaluating to false for some bizarre reason. > > > > > > > > i even tried > > > > > > > > <% for f in @flash %> > > > > FLASH VAL: <%= f %> > > > > <% end %> > > > > > > > > nothing.. still coming up fine in the view however. > > > > > > > > adam > > > > > > > > On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: > > > > > > > >> i am seeing "MESSAGE" which is why i stuck it in there. Just seems > > > >> like the layout wont grab the @flash variable, not sure why. > > > >> > > > >> I have tried @flash[:notice], flash[:notice].. removed and put back > > > >> <div id=notice> tags.. nothing... > > > >> > > > >> stumped. > > > >> > > > >> adam > > > >> > > > >> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: > > > >> > > > >> > > > >>> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor > > > >>> edits here for clarity: > > > >>> > > > >>> "So, the logging worked. But the flash message didn''t appear on the > > > >>> user''s browser. That''s because we didn''t display it. We''ll need to > > > >>> add something to the layout to tell it to display flash messages if > > > >>> they exist. The following rhtml code checks for a notice-level flash > > > >>> message and creates a new <div> containing it if necessary. > > > >>> > > > >>> <% if @flash[:notice] -%> > > > >>> <div id="notice"><%= @flash[:notice] %></div> > > > >>> <% end -%>" > > > >>> > > > >>> Note that the key is checking @flash, not some other variable which > > > >>> may be local to the view, but not the layout (is that really > > correct?). > > > >>> > > > >>> > > > >>> > > > >>>> yes b/c it shows up in my list, and also if i move the flash > > [:notice] > > > >>>> to the view, and out of the layout it works ok. I cant figure out > > > >>>> why it would work in a view, and not in a layout. any ideas ? > > > >>>> > > > >>>> > > > >>> > > > > >>> > > > >>> > > > >>>>>> Are you sure the location object is being saved (since when it is > > > >>>>>> not saved, flash isn''t set)? You can test using @location.save! > > > >>>>>> which will raise a RecordInvalid exception if the object can''t be > > > >>>>>> saved. > > > >>>>>> > > > >>>>>> > > > >>> > > > >>> > > > >>> > > > >>> _______________________________________________ > > > >>> Rails mailing list > > > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > > > >>> > > > >>> > > > >>> > > > >> > > > >> _______________________________________________ > > > >> Rails mailing list > > > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > >> > > > >> > > > > > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > ------------------------------------------ > David Siñuela Pastor (siu) > http://www.4coders.com > E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Brock Weaver [OBC]Technique
On Aug 26, 2005, at 10:35, Adam Denenberg wrote:> tried all of these with the same results. Production / dev, > quotes, no quotes.. nothing seems to work.1. Take everything out of your action, except setting the flash. Make sure this is the only thing the controller is doing. 2. Take everything out of your template except a simple "this is the template" text. 3. Take everything out of your layout, except for the code to show the flash. Now confirm that the flash is working. 4. Put things back in, one by one. If/when the flash stops working look carefully at the pieces you put back in place and find the error. - ask -- http://www.askbjoernhansen.com/
Then I have no more clues to add. Other than to ask if you have tried copying the code I supplied in an earlier posting, and see if that works? Because, that works in my code, and I am not doing any other kind of magic as far as I can see. If that doesn''t help I really don''t know how to help. My best guess would be that your problem isn''t actually "there", but in surrounding code... ------------------------------------------------------------------------ /*Ronny Hanssen*/ Adam Denenberg wrote:> tried all of these with the same results. Production / dev, quotes, no > quotes.. nothing seems to work. > > > On Aug 26, 2005, at 10:05 AM, David Siñuela wrote: > >> Hello, >> >> Be careful with the cache, look at your public folder for cached html >> pages.. >> >> I had this problem too ;) >> >> 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >>> I had the same problem. I didn''t do anything "special" to solve it, >>> just the >>> folling: >>> 1) In my controller, I always use the syntax: flash["notice"] = >>> "this is my >>> flash text" >>> 2) In my view file, I always check if @flash["notice"] >>> 3) If I see a problem, I restart the webrick server in mode "-e >>> production", and I check that in this mode no problem occurs. >>> >>> I believe points 1 and 2 are not really useful, my opinion is that >>> only >>> point 3) is relevant. >>> . >>> >>> >>> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: >>> >>>> You''ve also made sure that you''ve been using the flash[:notice] >>>> without >>>> the @-sign both places? Also in the if test? >>>> >>>> I can''t spot any other problem. In my code I am using it without the >>>> @-sign. And it works. In my controller-action I have: >>>> >>>> def edit >>>> @article = Article.find(params[:id]) >>>> if params[:article] and >>>> >>> @article.update_attributes(params[:article]) >>> >>>> flash[:notice] = ''Article was successfully updated.'' >>>> render :action => ''show'' >>>> end >>>> end >>>> >>>> And in my layout file I am using: >>>> >>>> <% if flash[:notice] %> >>>> <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> >>>> <% flash[:notice] = nil %> >>>> <% end %> >>>> >>>> That works at least. I''m not sure if I''m supposed to nil the >>>> flash[:notice] after use. I think I added it because the message >>>> seemed >>>> to be stuck longer than it should, somehow. >>>> >>>> >>>> >>> --------------------------------------------------------------------- >>> --- >>> >>>> /*Ronny Hanssen*/ >>>> >>>> >>>> Adam Denenberg wrote: >>>> >>>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which means >>>>> @flash[:notice] is evaluating to false for some bizarre reason. >>>>> >>>>> i even tried >>>>> >>>>> <% for f in @flash %> >>>>> FLASH VAL: <%= f %> >>>>> <% end %> >>>>> >>>>> nothing.. still coming up fine in the view however. >>>>> >>>>> adam >>>>> >>>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: >>>>> >>>>> >>>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just seems >>>>>> like the layout wont grab the @flash variable, not sure why. >>>>>> >>>>>> I have tried @flash[:notice], flash[:notice].. removed and put back >>>>>> <div id=notice> tags.. nothing... >>>>>> >>>>>> stumped. >>>>>> >>>>>> adam >>>>>> >>>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: >>>>>> >>>>>> >>>>>> >>>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. Minor >>>>>>> edits here for clarity: >>>>>>> >>>>>>> "So, the logging worked. But the flash message didn''t appear on >>>>>>> the >>>>>>> user''s browser. That''s because we didn''t display it. We''ll need to >>>>>>> add something to the layout to tell it to display flash >>>>>>> messages if >>>>>>> they exist. The following rhtml code checks for a notice- level >>>>>>> flash >>>>>>> message and creates a new <div> containing it if necessary. >>>>>>> >>>>>>> <% if @flash[:notice] -%> >>>>>>> <div id="notice"><%= @flash[:notice] %></div> >>>>>>> <% end -%>" >>>>>>> >>>>>>> Note that the key is checking @flash, not some other variable >>>>>>> which >>>>>>> may be local to the view, but not the layout (is that really >>>>>>> >>> correct?). >>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> yes b/c it shows up in my list, and also if i move the flash >>>>>>>> >>> [:notice] >>> >>>>>>>> to the view, and out of the layout it works ok. I cant figure >>>>>>>> out >>>>>>>> why it would work in a view, and not in a layout. any ideas ? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> Are you sure the location object is being saved (since when >>>>>>>>>> it is >>>>>>>>>> not saved, flash isn''t set)? You can test using @location.save! >>>>>>>>>> which will raise a RecordInvalid exception if the object >>>>>>>>>> can''t be >>>>>>>>>> saved. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Rails mailing list >>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Rails mailing list >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>> >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>> >> >> >> -- >> ------------------------------------------ >> David Siñuela Pastor (siu) >> http://www.4coders.com >> E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
nope no double redirect. My biggest issue is that it works in the list_locations.rhtml view, but not in the layout that list_locations uses. Still unable to figure out why this would be the case. adam On Aug 26, 2005, at 4:14 PM, Brock Weaver wrote:> You''re not accidentally doing a double-redirect are you? I mean, > when you: > > flash[:notice] = ''Location was successfully created.'' > redirect_to :action => ''list_locations'' > > Does your list_actions method redirect? The flash[:notice] is removed > from the session automatically after 1 round trip (or zero if you use > flash_now). You are performing one redirect in the code above, and if > the code in that function performs a redirect, your flash[:notice] > will die off on the first one. > > > On 8/26/05, David Siñuela <siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hello, >> >> Be careful with the cache, look at your public folder for cached >> html pages. >> >> I had this problem too ;) >> >> 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >>> I had the same problem. I didn''t do anything "special" to solve >>> it, just the >>> folling: >>> 1) In my controller, I always use the syntax: flash["notice"] = >>> "this is my >>> flash text" >>> 2) In my view file, I always check if @flash["notice"] >>> 3) If I see a problem, I restart the webrick server in mode "-e >>> production", and I check that in this mode no problem occurs. >>> >>> I believe points 1 and 2 are not really useful, my opinion is >>> that only >>> point 3) is relevant. >>> . >>> >>> >>> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: >>> >>>> You''ve also made sure that you''ve been using the flash[:notice] >>>> without >>>> the @-sign both places? Also in the if test? >>>> >>>> I can''t spot any other problem. In my code I am using it without >>>> the >>>> @-sign. And it works. In my controller-action I have: >>>> >>>> def edit >>>> @article = Article.find(params[:id]) >>>> if params[:article] and >>>> >>> @article.update_attributes(params[:article]) >>> >>>> flash[:notice] = ''Article was successfully >>>> updated.'' >>>> render :action => ''show'' >>>> end >>>> end >>>> >>>> And in my layout file I am using: >>>> >>>> <% if flash[:notice] %> >>>> <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> >>>> <% flash[:notice] = nil %> >>>> <% end %> >>>> >>>> That works at least. I''m not sure if I''m supposed to nil the >>>> flash[:notice] after use. I think I added it because the message >>>> seemed >>>> to be stuck longer than it should, somehow. >>>> >>>> >>>> >>> -------------------------------------------------------------------- >>> ---- >>> >>>> /*Ronny Hanssen*/ >>>> >>>> >>>> Adam Denenberg wrote: >>>> >>>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which >>>>> means >>>>> @flash[:notice] is evaluating to false for some bizarre reason. >>>>> >>>>> i even tried >>>>> >>>>> <% for f in @flash %> >>>>> FLASH VAL: <%= f %> >>>>> <% end %> >>>>> >>>>> nothing.. still coming up fine in the view however. >>>>> >>>>> adam >>>>> >>>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: >>>>> >>>>> >>>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just >>>>>> seems >>>>>> like the layout wont grab the @flash variable, not sure why. >>>>>> >>>>>> I have tried @flash[:notice], flash[:notice].. removed and put >>>>>> back >>>>>> <div id=notice> tags.. nothing... >>>>>> >>>>>> stumped. >>>>>> >>>>>> adam >>>>>> >>>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: >>>>>> >>>>>> >>>>>> >>>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. >>>>>>> Minor >>>>>>> edits here for clarity: >>>>>>> >>>>>>> "So, the logging worked. But the flash message didn''t appear >>>>>>> on the >>>>>>> user''s browser. That''s because we didn''t display it. We''ll >>>>>>> need to >>>>>>> add something to the layout to tell it to display flash >>>>>>> messages if >>>>>>> they exist. The following rhtml code checks for a notice- >>>>>>> level flash >>>>>>> message and creates a new <div> containing it if necessary. >>>>>>> >>>>>>> <% if @flash[:notice] -%> >>>>>>> <div id="notice"><%= @flash[:notice] %></div> >>>>>>> <% end -%>" >>>>>>> >>>>>>> Note that the key is checking @flash, not some other >>>>>>> variable which >>>>>>> may be local to the view, but not the layout (is that really >>>>>>> >>> correct?). >>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> yes b/c it shows up in my list, and also if i move the flash >>>>>>>> >>> [:notice] >>> >>>>>>>> to the view, and out of the layout it works ok. I cant >>>>>>>> figure out >>>>>>>> why it would work in a view, and not in a layout. any ideas ? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>>>> Are you sure the location object is being saved (since >>>>>>>>>> when it is >>>>>>>>>> not saved, flash isn''t set)? You can test using >>>>>>>>>> @location.save! >>>>>>>>>> which will raise a RecordInvalid exception if the object >>>>>>>>>> can''t be >>>>>>>>>> saved. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Rails mailing list >>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Rails mailing list >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>> >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>> >>> >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>> >> >> >> -- >> ------------------------------------------ >> David Siñuela Pastor (siu) >> http://www.4coders.com >> E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > > -- > Brock Weaver > [OBC]Technique > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Wat time are we meeting? 6pm. I''ll leave at 5.30. -----Original Message----- From: Ask Bjørn Hansen [mailto:ask-LxHg3dlN6iy+XT7JhA+gdA@public.gmane.org] Sent: Saturday, 27 August 2005 8:50 AM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] flash not working On Aug 26, 2005, at 10:35, Adam Denenberg wrote:> tried all of these with the same results. Production / dev, > quotes, no quotes.. nothing seems to work.1. Take everything out of your action, except setting the flash. Make sure this is the only thing the controller is doing. 2. Take everything out of your template except a simple "this is the template" text. 3. Take everything out of your layout, except for the code to show the flash. Now confirm that the flash is working. 4. Put things back in, one by one. If/when the flash stops working look carefully at the pieces you put back in place and find the error. - ask -- http://www.askbjoernhansen.com/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I''m running in to the same issue and it''s driving me crazy. If I put the line debug @flash in both application.rhtml and in the template that''s being rendered inside of the global application template, and only the inner template debug statement shows mappings in the hash. The application.rhtml statement shows an empty flash hash. Evan On Aug 27, 2005, at 2:14 AM, Adam Denenberg wrote:> nope no double redirect. My biggest issue is that it works in the > list_locations.rhtml view, but not in the layout that > list_locations uses. Still unable to figure out why this would be > the case. > > adam > > On Aug 26, 2005, at 4:14 PM, Brock Weaver wrote: > > >> You''re not accidentally doing a double-redirect are you? I mean, >> when you: >> >> flash[:notice] = ''Location was successfully created.'' >> redirect_to :action => ''list_locations'' >> >> Does your list_actions method redirect? The flash[:notice] is >> removed >> from the session automatically after 1 round trip (or zero if you use >> flash_now). You are performing one redirect in the code above, >> and if >> the code in that function performs a redirect, your flash[:notice] >> will die off on the first one. >> >> >> On 8/26/05, David Siñuela <siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >>> Hello, >>> >>> Be careful with the cache, look at your public folder for cached >>> html pages. >>> >>> I had this problem too ;) >>> >>> 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >>> >>> >>>> I had the same problem. I didn''t do anything "special" to solve >>>> it, just the >>>> folling: >>>> 1) In my controller, I always use the syntax: flash["notice"] = >>>> "this is my >>>> flash text" >>>> 2) In my view file, I always check if @flash["notice"] >>>> 3) If I see a problem, I restart the webrick server in mode "-e >>>> production", and I check that in this mode no problem occurs. >>>> >>>> I believe points 1 and 2 are not really useful, my opinion is >>>> that only >>>> point 3) is relevant. >>>> . >>>> >>>> >>>> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: >>>> >>>> >>>>> You''ve also made sure that you''ve been using the flash[:notice] >>>>> without >>>>> the @-sign both places? Also in the if test? >>>>> >>>>> I can''t spot any other problem. In my code I am using it >>>>> without the >>>>> @-sign. And it works. In my controller-action I have: >>>>> >>>>> def edit >>>>> @article = Article.find(params[:id]) >>>>> if params[:article] and >>>>> >>>>> >>>> @article.update_attributes(params[:article]) >>>> >>>> >>>>> flash[:notice] = ''Article was successfully >>>>> updated.'' >>>>> render :action => ''show'' >>>>> end >>>>> end >>>>> >>>>> And in my layout file I am using: >>>>> >>>>> <% if flash[:notice] %> >>>>> <%= "<div class=''notices''>" + flash[:notice] + "</div>" %> >>>>> <% flash[:notice] = nil %> >>>>> <% end %> >>>>> >>>>> That works at least. I''m not sure if I''m supposed to nil the >>>>> flash[:notice] after use. I think I added it because the >>>>> message seemed >>>>> to be stuck longer than it should, somehow. >>>>> >>>>> >>>>> >>>>> >>>> ------------------------------------------------------------------- >>>> ----- >>>> >>>> >>>>> /*Ronny Hanssen*/ >>>>> >>>>> >>>>> Adam Denenberg wrote: >>>>> >>>>> >>>>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which >>>>>> means >>>>>> @flash[:notice] is evaluating to false for some bizarre reason. >>>>>> >>>>>> i even tried >>>>>> >>>>>> <% for f in @flash %> >>>>>> FLASH VAL: <%= f %> >>>>>> <% end %> >>>>>> >>>>>> nothing.. still coming up fine in the view however. >>>>>> >>>>>> adam >>>>>> >>>>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: >>>>>> >>>>>> >>>>>> >>>>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just >>>>>>> seems >>>>>>> like the layout wont grab the @flash variable, not sure why. >>>>>>> >>>>>>> I have tried @flash[:notice], flash[:notice].. removed and >>>>>>> put back >>>>>>> <div id=notice> tags.. nothing... >>>>>>> >>>>>>> stumped. >>>>>>> >>>>>>> adam >>>>>>> >>>>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. >>>>>>>> Minor >>>>>>>> edits here for clarity: >>>>>>>> >>>>>>>> "So, the logging worked. But the flash message didn''t appear >>>>>>>> on the >>>>>>>> user''s browser. That''s because we didn''t display it. We''ll >>>>>>>> need to >>>>>>>> add something to the layout to tell it to display flash >>>>>>>> messages if >>>>>>>> they exist. The following rhtml code checks for a notice- >>>>>>>> level flash >>>>>>>> message and creates a new <div> containing it if necessary. >>>>>>>> >>>>>>>> <% if @flash[:notice] -%> >>>>>>>> <div id="notice"><%= @flash[:notice] %></div> >>>>>>>> <% end -%>" >>>>>>>> >>>>>>>> Note that the key is checking @flash, not some other >>>>>>>> variable which >>>>>>>> may be local to the view, but not the layout (is that really >>>>>>>> >>>>>>>> >>>> correct?). >>>> >>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> yes b/c it shows up in my list, and also if i move the flash >>>>>>>>> >>>>>>>>> >>>> [:notice] >>>> >>>> >>>>>>>>> to the view, and out of the layout it works ok. I cant >>>>>>>>> figure out >>>>>>>>> why it would work in a view, and not in a layout. any >>>>>>>>> ideas ? >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>>>> Are you sure the location object is being saved (since >>>>>>>>>>> when it is >>>>>>>>>>> not saved, flash isn''t set)? You can test using >>>>>>>>>>> @location.save! >>>>>>>>>>> which will raise a RecordInvalid exception if the object >>>>>>>>>>> can''t be >>>>>>>>>>> saved. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Rails mailing list >>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Rails mailing list >>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Rails mailing list >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>> >>>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>>> >>>>> >>>> >>>> >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>>> >>>> >>>> >>> >>> >>> -- >>> ------------------------------------------ >>> David Siñuela Pastor (siu) >>> http://www.4coders.com >>> E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>> Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >> >> >> -- >> Brock Weaver >> [OBC]Technique >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
thanks for the great advice. I finally identified that removing this piece of code in the header (a css <script> header thats gets "rendered" in the layout) is the problem calling this in the header: <%= render_component (:controller => "content", :action => "cssheader_admin") %> generates this css output.. Anybody see how this CSS code would effect flash ? body.admin_locations #menu li#nav_locations a { background : #fff; border-bottom : 1px solid #fff; color : #f00; font-weight: bold; } body.admin_locations #menu ul#subnav_locations { display : inline; left : 10px; position : absolute; top : 95px; } body.admin_locations #menu ul#subnav_locations a { background : #fff; border : none; border-left : 1px solid #ccc; color : #999; font-size : smaller; font-weight : bold; line-height : 10px; margin-right : 4px; padding : 2px 10px 2px 10px; text-decoration : none; } On Aug 26, 2005, at 6:49 PM, Ask Bjørn Hansen wrote:> > On Aug 26, 2005, at 10:35, Adam Denenberg wrote: > > >> tried all of these with the same results. Production / dev, >> quotes, no quotes.. nothing seems to work. >> > > 1. Take everything out of your action, except setting the flash. > Make sure this is the only thing the controller is doing. > > 2. Take everything out of your template except a simple "this is > the template" text. > > 3. Take everything out of your layout, except for the code to show > the flash. > > Now confirm that the flash is working. > > 4. Put things back in, one by one. If/when the flash stops working > look carefully at the pieces you put back in place and find the error. > > > - ask > > -- > http://www.askbjoernhansen.com/ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
maybe there is a hidden bug here? If you could try and reproduce the way i did (remove all code, see if it works, then slowly put pieces back until it breaks) maybe we can see if we can identify some sort of bug in rails.. adam On Aug 27, 2005, at 11:13 AM, Evan DiBiase wrote:> I''m running in to the same issue and it''s driving me crazy. If I > put the line > > debug @flash > > in both application.rhtml and in the template that''s being rendered > inside of the global application template, and only the inner > template debug statement shows mappings in the hash. The > application.rhtml statement shows an empty flash hash. > > Evan > > On Aug 27, 2005, at 2:14 AM, Adam Denenberg wrote: > > >> nope no double redirect. My biggest issue is that it works in the >> list_locations.rhtml view, but not in the layout that >> list_locations uses. Still unable to figure out why this would be >> the case. >> >> adam >> >> On Aug 26, 2005, at 4:14 PM, Brock Weaver wrote: >> >> >> >>> You''re not accidentally doing a double-redirect are you? I mean, >>> when you: >>> >>> flash[:notice] = ''Location was successfully created.'' >>> redirect_to :action => ''list_locations'' >>> >>> Does your list_actions method redirect? The flash[:notice] is >>> removed >>> from the session automatically after 1 round trip (or zero if you >>> use >>> flash_now). You are performing one redirect in the code above, >>> and if >>> the code in that function performs a redirect, your flash[:notice] >>> will die off on the first one. >>> >>> >>> On 8/26/05, David Siñuela <siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> >>> >>>> Hello, >>>> >>>> Be careful with the cache, look at your public folder for cached >>>> html pages. >>>> >>>> I had this problem too ;) >>>> >>>> 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >>>> >>>> >>>> >>>>> I had the same problem. I didn''t do anything "special" to solve >>>>> it, just the >>>>> folling: >>>>> 1) In my controller, I always use the syntax: flash["notice"] >>>>> = "this is my >>>>> flash text" >>>>> 2) In my view file, I always check if @flash["notice"] >>>>> 3) If I see a problem, I restart the webrick server in mode "-e >>>>> production", and I check that in this mode no problem occurs. >>>>> >>>>> I believe points 1 and 2 are not really useful, my opinion is >>>>> that only >>>>> point 3) is relevant. >>>>> . >>>>> >>>>> >>>>> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: >>>>> >>>>> >>>>> >>>>>> You''ve also made sure that you''ve been using the flash >>>>>> [:notice] without >>>>>> the @-sign both places? Also in the if test? >>>>>> >>>>>> I can''t spot any other problem. In my code I am using it >>>>>> without the >>>>>> @-sign. And it works. In my controller-action I have: >>>>>> >>>>>> def edit >>>>>> @article = Article.find(params[:id]) >>>>>> if params[:article] and >>>>>> >>>>>> >>>>>> >>>>> @article.update_attributes(params[:article]) >>>>> >>>>> >>>>> >>>>>> flash[:notice] = ''Article was successfully >>>>>> updated.'' >>>>>> render :action => ''show'' >>>>>> end >>>>>> end >>>>>> >>>>>> And in my layout file I am using: >>>>>> >>>>>> <% if flash[:notice] %> >>>>>> <%= "<div class=''notices''>" + flash[:notice] + "</ >>>>>> div>" %> >>>>>> <% flash[:notice] = nil %> >>>>>> <% end %> >>>>>> >>>>>> That works at least. I''m not sure if I''m supposed to nil the >>>>>> flash[:notice] after use. I think I added it because the >>>>>> message seemed >>>>>> to be stuck longer than it should, somehow. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> ------------------------------------------------------------------ >>>>> ------ >>>>> >>>>> >>>>> >>>>>> /*Ronny Hanssen*/ >>>>>> >>>>>> >>>>>> Adam Denenberg wrote: >>>>>> >>>>>> >>>>>> >>>>>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which >>>>>>> means >>>>>>> @flash[:notice] is evaluating to false for some bizarre reason. >>>>>>> >>>>>>> i even tried >>>>>>> >>>>>>> <% for f in @flash %> >>>>>>> FLASH VAL: <%= f %> >>>>>>> <% end %> >>>>>>> >>>>>>> nothing.. still coming up fine in the view however. >>>>>>> >>>>>>> adam >>>>>>> >>>>>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just >>>>>>>> seems >>>>>>>> like the layout wont grab the @flash variable, not sure why. >>>>>>>> >>>>>>>> I have tried @flash[:notice], flash[:notice].. removed and >>>>>>>> put back >>>>>>>> <div id=notice> tags.. nothing... >>>>>>>> >>>>>>>> stumped. >>>>>>>> >>>>>>>> adam >>>>>>>> >>>>>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. >>>>>>>>> Minor >>>>>>>>> edits here for clarity: >>>>>>>>> >>>>>>>>> "So, the logging worked. But the flash message didn''t >>>>>>>>> appear on the >>>>>>>>> user''s browser. That''s because we didn''t display it. We''ll >>>>>>>>> need to >>>>>>>>> add something to the layout to tell it to display flash >>>>>>>>> messages if >>>>>>>>> they exist. The following rhtml code checks for a notice- >>>>>>>>> level flash >>>>>>>>> message and creates a new <div> containing it if necessary. >>>>>>>>> >>>>>>>>> <% if @flash[:notice] -%> >>>>>>>>> <div id="notice"><%= @flash[:notice] %></div> >>>>>>>>> <% end -%>" >>>>>>>>> >>>>>>>>> Note that the key is checking @flash, not some other >>>>>>>>> variable which >>>>>>>>> may be local to the view, but not the layout (is that really >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>> correct?). >>>>> >>>>> >>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> yes b/c it shows up in my list, and also if i move the flash >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>> [:notice] >>>>> >>>>> >>>>> >>>>>>>>>> to the view, and out of the layout it works ok. I cant >>>>>>>>>> figure out >>>>>>>>>> why it would work in a view, and not in a layout. any >>>>>>>>>> ideas ? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>>>> Are you sure the location object is being saved (since >>>>>>>>>>>> when it is >>>>>>>>>>>> not saved, flash isn''t set)? You can test using >>>>>>>>>>>> @location.save! >>>>>>>>>>>> which will raise a RecordInvalid exception if the object >>>>>>>>>>>> can''t be >>>>>>>>>>>> saved. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> _______________________________________________ >>>>>>>>> Rails mailing list >>>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Rails mailing list >>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Rails mailing list >>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>>> >>>>>>> >>>>>>> >>>>>> _______________________________________________ >>>>>> Rails mailing list >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> Rails mailing list >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> ------------------------------------------ >>>> David Siñuela Pastor (siu) >>>> http://www.4coders.com >>>> E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >>>> Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org >>>> _______________________________________________ >>>> Rails mailing list >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>> http://lists.rubyonrails.org/mailman/listinfo/rails >>>> >>>> >>>> >>>> >>> >>> >>> -- >>> Brock Weaver >>> [OBC]Technique >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
If the code you included is *all* the code, then I don''t see how the page is to recognize it as being CSS. But I guess that you must have added style tags, otherwise this would all just show on the page... The CSS in itself looks good though. However, you are calling another component, and I am not sure how this affects the flash contents though. Maybe someone else more experienced knows? ------------------------------------------------------------------------ /*Ronny Hanssen*/ Adam Denenberg wrote:> thanks for the great advice. I finally identified that removing this > piece of code in the header (a css <script> header thats gets > "rendered" in the layout) is the problem > > calling this in the header: <%= render_component (:controller => > "content", :action => "cssheader_admin") %> > > generates this css output.. Anybody see how this CSS code would effect > flash ? > > > body.admin_locations #menu li#nav_locations a { > background : #fff; > border-bottom : 1px solid #fff; > color : #f00; > font-weight: bold; > } > > body.admin_locations #menu ul#subnav_locations { > display : inline; > left : 10px; > position : absolute; > top : 95px; > } > > body.admin_locations #menu ul#subnav_locations a { > background : #fff; > border : none; > border-left : 1px solid #ccc; > color : #999; > font-size : smaller; > font-weight : bold; > line-height : 10px; > margin-right : 4px; > padding : 2px 10px 2px 10px; > text-decoration : none; > } > > On Aug 26, 2005, at 6:49 PM, Ask Bjørn Hansen wrote: > >> >> On Aug 26, 2005, at 10:35, Adam Denenberg wrote: >> >> >>> tried all of these with the same results. Production / dev, quotes, >>> no quotes.. nothing seems to work. >>> >> >> 1. Take everything out of your action, except setting the flash. >> Make sure this is the only thing the controller is doing. >> >> 2. Take everything out of your template except a simple "this is the >> template" text. >> >> 3. Take everything out of your layout, except for the code to show >> the flash. >> >> Now confirm that the flash is working. >> >> 4. Put things back in, one by one. If/when the flash stops working >> look carefully at the pieces you put back in place and find the error. >> >> >> - ask >> >> -- >> http://www.askbjoernhansen.com/ >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I got bitten by this exact same problem. The deal is, rendering a component counts as a render, which clears the flash. I worked around it by adding a freeze method to the flash, which gets called before rendering the component. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I am having the same problem. In my case, it is caused by calling render_component in the layout before trying to display the flash notice. I believe the issue is that the render_component is clearing the flash notice. To reproduce this, try creating a layout that does the following: <%= flash[:notice] %> <%= render_component(:controller => ''foo'', :action=> ''bar'') %> <%= flash[:notice] %> The first flash will display, the second one will not. Tom On 8/28/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote:> > maybe there is a hidden bug here? If you could try and reproduce the > way i did (remove all code, see if it works, then slowly put pieces > back until it breaks) maybe we can see if we can identify some sort > of bug in rails.. > > adam > > On Aug 27, 2005, at 11:13 AM, Evan DiBiase wrote: > > > I''m running in to the same issue and it''s driving me crazy. If I > > put the line > > > > debug @flash > > > > in both application.rhtml and in the template that''s being rendered > > inside of the global application template, and only the inner > > template debug statement shows mappings in the hash. The > > application.rhtml statement shows an empty flash hash. > > > > Evan > > > > On Aug 27, 2005, at 2:14 AM, Adam Denenberg wrote: > > > > > >> nope no double redirect. My biggest issue is that it works in the > >> list_locations.rhtml view, but not in the layout that > >> list_locations uses. Still unable to figure out why this would be > >> the case. > >> > >> adam > >> > >> On Aug 26, 2005, at 4:14 PM, Brock Weaver wrote: > >> > >> > >> > >>> You''re not accidentally doing a double-redirect are you? I mean, > >>> when you: > >>> > >>> flash[:notice] = ''Location was successfully created.'' > >>> redirect_to :action => ''list_locations'' > >>> > >>> Does your list_actions method redirect? The flash[:notice] is > >>> removed > >>> from the session automatically after 1 round trip (or zero if you > >>> use > >>> flash_now). You are performing one redirect in the code above, > >>> and if > >>> the code in that function performs a redirect, your flash[:notice] > >>> will die off on the first one. > >>> > >>> > >>> On 8/26/05, David Siñuela <siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> > >>> > >>> > >>>> Hello, > >>>> > >>>> Be careful with the cache, look at your public folder for cached > >>>> html pages. > >>>> > >>>> I had this problem too ;) > >>>> > >>>> 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >>>> > >>>> > >>>> > >>>>> I had the same problem. I didn''t do anything "special" to solve > >>>>> it, just the > >>>>> folling: > >>>>> 1) In my controller, I always use the syntax: flash["notice"] > >>>>> = "this is my > >>>>> flash text" > >>>>> 2) In my view file, I always check if @flash["notice"] > >>>>> 3) If I see a problem, I restart the webrick server in mode "-e > >>>>> production", and I check that in this mode no problem occurs. > >>>>> > >>>>> I believe points 1 and 2 are not really useful, my opinion is > >>>>> that only > >>>>> point 3) is relevant. > >>>>> . > >>>>> > >>>>> > >>>>> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: > >>>>> > >>>>> > >>>>> > >>>>>> You''ve also made sure that you''ve been using the flash > >>>>>> [:notice] without > >>>>>> the @-sign both places? Also in the if test? > >>>>>> > >>>>>> I can''t spot any other problem. In my code I am using it > >>>>>> without the > >>>>>> @-sign. And it works. In my controller-action I have: > >>>>>> > >>>>>> def edit > >>>>>> @article = Article.find(params[:id]) > >>>>>> if params[:article] and > >>>>>> > >>>>>> > >>>>>> > >>>>> @article.update_attributes(params[:article]) > >>>>> > >>>>> > >>>>> > >>>>>> flash[:notice] = ''Article was successfully > >>>>>> updated.'' > >>>>>> render :action => ''show'' > >>>>>> end > >>>>>> end > >>>>>> > >>>>>> And in my layout file I am using: > >>>>>> > >>>>>> <% if flash[:notice] %> > >>>>>> <%= "<div class=''notices''>" + flash[:notice] + "</ > >>>>>> div>" %> > >>>>>> <% flash[:notice] = nil %> > >>>>>> <% end %> > >>>>>> > >>>>>> That works at least. I''m not sure if I''m supposed to nil the > >>>>>> flash[:notice] after use. I think I added it because the > >>>>>> message seemed > >>>>>> to be stuck longer than it should, somehow. > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>> ------------------------------------------------------------------ > >>>>> ------ > >>>>> > >>>>> > >>>>> > >>>>>> /*Ronny Hanssen*/ > >>>>>> > >>>>>> > >>>>>> Adam Denenberg wrote: > >>>>>> > >>>>>> > >>>>>> > >>>>>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which > >>>>>>> means > >>>>>>> @flash[:notice] is evaluating to false for some bizarre reason. > >>>>>>> > >>>>>>> i even tried > >>>>>>> > >>>>>>> <% for f in @flash %> > >>>>>>> FLASH VAL: <%= f %> > >>>>>>> <% end %> > >>>>>>> > >>>>>>> nothing.. still coming up fine in the view however. > >>>>>>> > >>>>>>> adam > >>>>>>> > >>>>>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just > >>>>>>>> seems > >>>>>>>> like the layout wont grab the @flash variable, not sure why. > >>>>>>>> > >>>>>>>> I have tried @flash[:notice], flash[:notice].. removed and > >>>>>>>> put back > >>>>>>>> <div id=notice> tags.. nothing... > >>>>>>>> > >>>>>>>> stumped. > >>>>>>>> > >>>>>>>> adam > >>>>>>>> > >>>>>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. > >>>>>>>>> Minor > >>>>>>>>> edits here for clarity: > >>>>>>>>> > >>>>>>>>> "So, the logging worked. But the flash message didn''t > >>>>>>>>> appear on the > >>>>>>>>> user''s browser. That''s because we didn''t display it. We''ll > >>>>>>>>> need to > >>>>>>>>> add something to the layout to tell it to display flash > >>>>>>>>> messages if > >>>>>>>>> they exist. The following rhtml code checks for a notice- > >>>>>>>>> level flash > >>>>>>>>> message and creates a new <div> containing it if necessary. > >>>>>>>>> > >>>>>>>>> <% if @flash[:notice] -%> > >>>>>>>>> <div id="notice"><%= @flash[:notice] %></div> > >>>>>>>>> <% end -%>" > >>>>>>>>> > >>>>>>>>> Note that the key is checking @flash, not some other > >>>>>>>>> variable which > >>>>>>>>> may be local to the view, but not the layout (is that really > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>> correct?). > >>>>> > >>>>> > >>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>>> yes b/c it shows up in my list, and also if i move the flash > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>> [:notice] > >>>>> > >>>>> > >>>>> > >>>>>>>>>> to the view, and out of the layout it works ok. I cant > >>>>>>>>>> figure out > >>>>>>>>>> why it would work in a view, and not in a layout. any > >>>>>>>>>> ideas ? > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>>>>> Are you sure the location object is being saved (since > >>>>>>>>>>>> when it is > >>>>>>>>>>>> not saved, flash isn''t set)? You can test using > >>>>>>>>>>>> @location.save! > >>>>>>>>>>>> which will raise a RecordInvalid exception if the object > >>>>>>>>>>>> can''t be > >>>>>>>>>>>> saved. > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> _______________________________________________ > >>>>>>>>> Rails mailing list > >>>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>> > >>>>>>>> _______________________________________________ > >>>>>>>> Rails mailing list > >>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>> > >>>>>>> _______________________________________________ > >>>>>>> Rails mailing list > >>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>> _______________________________________________ > >>>>>> Rails mailing list > >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> Rails mailing list > >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>> > >>>> > >>>> -- > >>>> ------------------------------------------ > >>>> David Siñuela Pastor (siu) > >>>> http://www.4coders.com > >>>> E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > >>>> Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org > >>>> _______________________________________________ > >>>> Rails mailing list > >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>>> > >>>> > >>>> > >>>> > >>> > >>> > >>> -- > >>> Brock Weaver > >>> [OBC]Technique > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > >>> > >>> > >>> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > >> > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
By the way, a quick workaround is to just save the notice at the top of your layout in a local variable: <% @mynotice = flash[:notice] -%> Then just use <%= @mynotice %>. Tom On 8/30/05, Tom Davies <atomgiant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am having the same problem. In my case, it is caused by calling > render_component in the layout before trying to display the flash notice. I > believe the issue is that the render_component is clearing the flash notice. > To reproduce this, try creating a layout that does the following: > > <%= flash[:notice] %> > <%= render_component(:controller => ''foo'', :action=> ''bar'') %> > <%= flash[:notice] %> > > The first flash will display, the second one will not. > > Tom > > On 8/28/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: > > > > maybe there is a hidden bug here? If you could try and reproduce the > > way i did (remove all code, see if it works, then slowly put pieces > > back until it breaks) maybe we can see if we can identify some sort > > of bug in rails.. > > > > adam > > > > On Aug 27, 2005, at 11:13 AM, Evan DiBiase wrote: > > > > > I''m running in to the same issue and it''s driving me crazy. If I > > > put the line > > > > > > debug @flash > > > > > > in both application.rhtml and in the template that''s being rendered > > > inside of the global application template, and only the inner > > > template debug statement shows mappings in the hash. The > > > application.rhtml statement shows an empty flash hash. > > > > > > Evan > > > > > > On Aug 27, 2005, at 2:14 AM, Adam Denenberg wrote: > > > > > > > > >> nope no double redirect. My biggest issue is that it works in the > > >> list_locations.rhtml view, but not in the layout that > > >> list_locations uses. Still unable to figure out why this would be > > >> the case. > > >> > > >> adam > > >> > > >> On Aug 26, 2005, at 4:14 PM, Brock Weaver wrote: > > >> > > >> > > >> > > >>> You''re not accidentally doing a double-redirect are you? I mean, > > >>> when you: > > >>> > > >>> flash[:notice] = ''Location was successfully created.'' > > >>> redirect_to :action => ''list_locations'' > > >>> > > >>> Does your list_actions method redirect? The flash[:notice] is > > >>> removed > > >>> from the session automatically after 1 round trip (or zero if you > > >>> use > > >>> flash_now). You are performing one redirect in the code above, > > >>> and if > > >>> the code in that function performs a redirect, your flash[:notice] > > >>> will die off on the first one. > > >>> > > >>> > > >>> On 8/26/05, David Siñuela <siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> > > >>> > > >>> > > >>>> Hello, > > >>>> > > >>>> Be careful with the cache, look at your public folder for cached > > >>>> html pages. > > >>>> > > >>>> I had this problem too ;) > > >>>> > > >>>> 2005/8/26, Nicolas Buet <nicolas.buet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > >>>> > > >>>> > > >>>> > > >>>>> I had the same problem. I didn''t do anything "special" to solve > > >>>>> it, just the > > >>>>> folling: > > >>>>> 1) In my controller, I always use the syntax: flash["notice"] > > >>>>> = "this is my > > >>>>> flash text" > > >>>>> 2) In my view file, I always check if @flash["notice"] > > >>>>> 3) If I see a problem, I restart the webrick server in mode "-e > > >>>>> production", and I check that in this mode no problem occurs. > > >>>>> > > >>>>> I believe points 1 and 2 are not really useful, my opinion is > > >>>>> that only > > >>>>> point 3) is relevant. > > >>>>> . > > >>>>> > > >>>>> > > >>>>> On 8/26/05, Ronny Hanssen <ronnyh-7tg5dEkr+6sdnm+yROfE0A@public.gmane.org> wrote: > > >>>>> > > >>>>> > > >>>>> > > >>>>>> You''ve also made sure that you''ve been using the flash > > >>>>>> [:notice] without > > >>>>>> the @-sign both places? Also in the if test? > > >>>>>> > > >>>>>> I can''t spot any other problem. In my code I am using it > > >>>>>> without the > > >>>>>> @-sign. And it works. In my controller-action I have: > > >>>>>> > > >>>>>> def edit > > >>>>>> @article = Article.find(params[:id]) > > >>>>>> if params[:article] and > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>> @article.update_attributes(params[:article]) > > >>>>> > > >>>>> > > >>>>> > > >>>>>> flash[:notice] = ''Article was successfully > > >>>>>> updated.'' > > >>>>>> render :action => ''show'' > > >>>>>> end > > >>>>>> end > > >>>>>> > > >>>>>> And in my layout file I am using: > > >>>>>> > > >>>>>> <% if flash[:notice] %> > > >>>>>> <%= "<div class=''notices''>" + flash[:notice] + "</ > > >>>>>> div>" %> > > >>>>>> <% flash[:notice] = nil %> > > >>>>>> <% end %> > > >>>>>> > > >>>>>> That works at least. I''m not sure if I''m supposed to nil the > > >>>>>> flash[:notice] after use. I think I added it because the > > >>>>>> message seemed > > >>>>>> to be stuck longer than it should, somehow. > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>> ------------------------------------------------------------------ > > > > >>>>> ------ > > >>>>> > > >>>>> > > >>>>> > > >>>>>> /*Ronny Hanssen*/ > > >>>>>> > > >>>>>> > > >>>>>> Adam Denenberg wrote: > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>>>> sorry mistyped.. I am _NOT_ seeing the MESSAGE pop up. Which > > >>>>>>> means > > >>>>>>> @flash[:notice] is evaluating to false for some bizarre reason. > > >>>>>>> > > >>>>>>> i even tried > > >>>>>>> > > >>>>>>> <% for f in @flash %> > > >>>>>>> FLASH VAL: <%= f %> > > >>>>>>> <% end %> > > >>>>>>> > > >>>>>>> nothing.. still coming up fine in the view however. > > >>>>>>> > > >>>>>>> adam > > >>>>>>> > > >>>>>>> On Aug 25, 2005, at 10:35 PM, Adam Denenberg wrote: > > >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>>>> i am seeing "MESSAGE" which is why i stuck it in there. Just > > >>>>>>>> seems > > >>>>>>>> like the layout wont grab the @flash variable, not sure why. > > >>>>>>>> > > >>>>>>>> I have tried @flash[:notice], flash[:notice].. removed and > > >>>>>>>> put back > > >>>>>>>> <div id=notice> tags.. nothing... > > >>>>>>>> > > >>>>>>>> stumped. > > >>>>>>>> > > >>>>>>>> adam > > >>>>>>>> > > >>>>>>>> On Aug 25, 2005, at 5:40 PM, Andrew Otwell wrote: > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>>> Agile Dev, page 88, shows how to put a flash[] in a layout. > > >>>>>>>>> Minor > > >>>>>>>>> edits here for clarity: > > >>>>>>>>> > > >>>>>>>>> "So, the logging worked. But the flash message didn''t > > >>>>>>>>> appear on the > > >>>>>>>>> user''s browser. That''s because we didn''t display it. We''ll > > >>>>>>>>> need to > > >>>>>>>>> add something to the layout to tell it to display flash > > >>>>>>>>> messages if > > >>>>>>>>> they exist. The following rhtml code checks for a notice- > > >>>>>>>>> level flash > > >>>>>>>>> message and creates a new <div> containing it if necessary. > > >>>>>>>>> > > >>>>>>>>> <% if @flash[:notice] -%> > > >>>>>>>>> <div id="notice"><%= @flash[:notice] %></div> > > >>>>>>>>> <% end -%>" > > >>>>>>>>> > > >>>>>>>>> Note that the key is checking @flash, not some other > > >>>>>>>>> variable which > > >>>>>>>>> may be local to the view, but not the layout (is that really > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>> correct?). > > >>>>> > > >>>>> > > >>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>>> yes b/c it shows up in my list, and also if i move the flash > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>> [:notice] > > >>>>> > > >>>>> > > >>>>> > > >>>>>>>>>> to the view, and out of the layout it works ok. I cant > > >>>>>>>>>> figure out > > >>>>>>>>>> why it would work in a view, and not in a layout. any > > >>>>>>>>>> ideas ? > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>>>>> Are you sure the location object is being saved (since > > >>>>>>>>>>>> when it is > > >>>>>>>>>>>> not saved, flash isn''t set)? You can test using > > >>>>>>>>>>>> @location.save! > > >>>>>>>>>>>> which will raise a RecordInvalid exception if the object > > >>>>>>>>>>>> can''t be > > >>>>>>>>>>>> saved. > > >>>>>>>>>>>> > > >>>>>>>>>>>> > > >>>>>>>>>>>> > > >>>>>>>>>>>> > > >>>>>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> _______________________________________________ > > >>>>>>>>> Rails mailing list > > >>>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>>> > > >>>>>>>> > > >>>>>>>> _______________________________________________ > > >>>>>>>> Rails mailing list > > >>>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>>> > > >>>>>>> > > >>>>>>> _______________________________________________ > > >>>>>>> Rails mailing list > > >>>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>>>>>> > > >>>>>>> > > >>>>>>> > > >>>>>> _______________________________________________ > > >>>>>> Rails mailing list > > >>>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > >>>>> > > >>>>> > > >>>>> _______________________________________________ > > >>>>> Rails mailing list > > >>>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>>>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>>>> > > >>>>> > > >>>>> > > >>>>> > > >>>>> > > >>>>> > > >>>> > > >>>> > > >>>> -- > > >>>> ------------------------------------------ > > >>>> David Siñuela Pastor (siu) > > >>>> http://www.4coders.com > > >>>> E-mail: siu.4coders-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > >>>> Jabber: siu-tVMmVOZxw5Bg9hUCZPvPmw@public.gmane.org > > >>>> _______________________________________________ > > >>>> Rails mailing list > > >>>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>>> > > >>>> > > >>>> > > >>>> > > >>> > > >>> > > >>> -- > > >>> Brock Weaver > > >>> [OBC]Technique > > >>> _______________________________________________ > > >>> Rails mailing list > > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > > >>> > > >>> > > >>> > > >>> > > >> > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > >> > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> If the code you included is *all* the code, then I don''t see how the > page is to recognize it as being CSS. But I guess that you must have<snip>> ------------------------------------------------------------------------ > /*Ronny Hanssen*/>>>Adam Denenberg wrote: >>> thanks for the great advice. I finally identified that removing >>> this piece of code in the header (a css <script> header thats >>> gets "rendered" in the layout) is the problem >>> >>> calling this in the header: <%= render_component (:controller => >>> "content", :action => "cssheader_admin") %> >>> >>> generates this css output.. Anybody see how this CSS code would >>> effect flash ?I agree with Ronny: the css you included should be fine and does not affect flash[] at all. Make sure that you''re NOT trying to write this: <script> .some_css_here {] </script> Which is what you imply in your comment about a "css script header." CSS should of course be rendered inside <style> tags: <style> .some_css_here {} </style> Andrew
Hi I hit that component error, too. There is a ticket in the RoR Trac instance: http://dev.rubyonrails.org/ticket/1858 I''ve posted a quick workaround there. Simply place <% # rendering a component sweeps the flash so we need to preserve it @flash = flash.dup %> before any component is rendered into your layout. Regards Manuel Holtgrewe
thanks michael. Where exactly do you add the freeze, in the action of the controller ? On Aug 29, 2005, at 8:11 PM, Michael Meckler wrote:> I got bitten by this exact same problem. The deal is, rendering a > component counts as a render, which clears the flash. I worked > around it by adding a freeze method to the flash, which gets called > before rendering the component. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
i actually did the following before my render component in the header (thanks for the heads up on the render thing, that saved me). <% if @flash[:notice] %> <% @message = @flash[:notice] %> <% end %> and then just usage @message later. seems to work fine. adam On Aug 29, 2005, at 8:11 PM, Michael Meckler wrote:> I got bitten by this exact same problem. The deal is, rendering a > component counts as a render, which clears the flash. I worked > around it by adding a freeze method to the flash, which gets called > before rendering the component. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >