hei
2008-Feb-21 03:39 UTC
Does a request and the request created by a "link_to ''xxx'', {:action => ''xx''} :popup => true " share flash?
I have a url called A, in its resource , this exists: <%= link_to ''XXX'', {:action => ''xxx''}, :popup => true %> and I click it and create a new request with url B Now I have two requests, or two browser pages A and B I click a submit button in B, it dose something back and show a Tip "Save correctly!" in top of B and I turn to A, and REFRESH it , and I see the same tip "Save correctly!" in top of A! in back end, I store the tip with flash[:notice] So it seems they share the flash, between requests ! Can anyone tells me why ? or tell me where i can find the answer. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Feb-21 04:14 UTC
Re: Does a request and the request created by a "link_to ''xx
I usually use it : class ApplicationController < ActionController::Base def reset_notice flash[:notice] = nil end end class MyRails < ApplicationController before_filter :reset_notice ... end Hope it''s helpful. ~*~*~*~**~*~*~*~*~*~*~*~ Reinhart Ariand YM : Booking2Heaven WEB: teapoci.blogspot.com ~*~*~*~**~*~*~*~*~*~*~*~ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jean Nibee
2008-Feb-21 04:56 UTC
Re: Does a request and the request created by a "link_to ''xx
Visit Indonesia 2008 wrote:> I usually use it : > > class ApplicationController < ActionController::Base > > def reset_notice > flash[:notice] = nil > end > > end > > class MyRails < ApplicationController > before_filter :reset_notice > > ... > > end > > > Hope it''s helpful. > > ~*~*~*~**~*~*~*~*~*~*~*~ > Reinhart Ariand > YM : Booking2Heaven > WEB: teapoci.blogspot.com > ~*~*~*~**~*~*~*~*~*~*~*~This will clear the flash container every time but sometimes you don''t WANT this to happen. (You''re overriding the default behaviour of the flash mechanism this way) If you do want a messages to last only for the life of the current request try this: flash.now[:notice] = "message" In the original post above it would show only for the submission of B but the refresh of A would not show the message. Hope this helps. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Feb-21 05:19 UTC
Re: Does a request and the request created by a "link_to ''xx
ohh.. sorry. I did miss understood. Next time i will read careful the posting. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you~ en, I have just learn the default behavior of the flash, i am confused... some guy says "Flash--Communicating between Actions" I thought flash is just a pre-defined hash between action and its view Can anyone tells me more details ? Or tell me where I can find the precise answer Thanks~ Jean Nibee wrote:> Visit Indonesia 2008 wrote: > > I usually use it : > > > > class ApplicationController < ActionController::Base > > > > def reset_notice > > flash[:notice] = nil > > end > > > > end > > > > class MyRails < ApplicationController > > before_filter :reset_notice > > > > ... > > > > end > > > > > > Hope it''s helpful. > > > > ~*~*~*~**~*~*~*~*~*~*~*~ > > Reinhart Ariand > > YM : Booking2Heaven > > WEB: teapoci.blogspot.com > > ~*~*~*~**~*~*~*~*~*~*~*~ > > This will clear the flash container every time but sometimes you don''t > WANT this to happen. (You''re overriding the default behaviour of the > flash mechanism this way) > > If you do want a messages to last only for the life of the current > request try this: > > flash.now[:notice] = "message" > > In the original post above it would show only for the submission of B > but the refresh of A would not show the message. > > Hope this helps. > -- > Posted via http://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you all the same ~~ On Feb 21, 1:19 pm, Visit Indonesia 2008 <rails-mailing-l...@andreas- s.net> wrote:> ohh.. sorry. I did miss understood. Next time i will read careful the > posting. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Feb-21 10:31 UTC
Re: Does a request and the request created by a "link_to ''xx
On 21 Feb 2008, at 08:07, hei wrote:> > Thank you~ > en, I have just learn the default behavior of the flash, i am > confused... > some guy says "Flash--Communicating between Actions" > I thought flash is just a pre-defined hash between action and its view > Can anyone tells me more details ? Or tell me where I can find the > precise answerthe flash is suppose to persist to the next request (but only the next request). If you set flash.now[:notice] = ... Then it won''t persist to the next request. Fred> > Thanks~ > Jean Nibee wrote: >> Visit Indonesia 2008 wrote: >>> I usually use it : >>> >>> class ApplicationController < ActionController::Base >>> >>> def reset_notice >>> flash[:notice] = nil >>> end >>> >>> end >>> >>> class MyRails < ApplicationController >>> before_filter :reset_notice >>> >>> ... >>> >>> end >>> >>> >>> Hope it''s helpful. >>> >>> ~*~*~*~**~*~*~*~*~*~*~*~ >>> Reinhart Ariand >>> YM : Booking2Heaven >>> WEB: teapoci.blogspot.com >>> ~*~*~*~**~*~*~*~*~*~*~*~ >> >> This will clear the flash container every time but sometimes you >> don''t >> WANT this to happen. (You''re overriding the default behaviour of the >> flash mechanism this way) >> >> If you do want a messages to last only for the life of the current >> request try this: >> >> flash.now[:notice] = "message" >> >> In the original post above it would show only for the submission >> of B >> but the refresh of A would not show the message. >> >> Hope this helps. >> -- >> Posted via http://www.ruby-forum.com/. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you~~ So an usual usage may be: def A flash[:notice] = "I came from ActionName A" redirect_to :action => B end am I right? On Feb 21, 6:31 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 21 Feb 2008, at 08:07, hei wrote: > > > > > Thank you~ > > en, I have just learn the default behavior of the flash, i am > > confused... > > some guy says "Flash--Communicating between Actions" > > I thought flash is just a pre-defined hash between action and its view > > Can anyone tells me more details ? Or tell me where I can find the > > precise answer > > the flash is suppose to persist to the next request (but only the next > request). If you set flash.now[:notice] = ... > Then it won''t persist to the next request. > > Fred > > > > > > > Thanks~ > > Jean Nibee wrote: > >> Visit Indonesia 2008 wrote: > >>> I usually use it : > > >>> class ApplicationController < ActionController::Base > > >>> def reset_notice > >>> flash[:notice] = nil > >>> end > > >>> end > > >>> class MyRails < ApplicationController > >>> before_filter :reset_notice > > >>> ... > > >>> end > > >>> Hope it''s helpful. > > >>> ~*~*~*~**~*~*~*~*~*~*~*~ > >>> Reinhart Ariand > >>> YM : Booking2Heaven > >>> WEB: teapoci.blogspot.com > >>> ~*~*~*~**~*~*~*~*~*~*~*~ > > >> This will clear the flash container every time but sometimes you > >> don''t > >> WANT this to happen. (You''re overriding the default behaviour of the > >> flash mechanism this way) > > >> If you do want a messages to last only for the life of the current > >> request try this: > > >> flash.now[:notice] = "message" > > >> In the original post above it would show only for the submission > >> of B > >> but the refresh of A would not show the message. > > >> Hope this helps. > >> -- > >> Posted viahttp://www.ruby-forum.com/.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Feb-22 01:59 UTC
Re: Does a request and the request created by a "link_to ''xx
You can not display that flash[:notice] on :action B because action B doesnt have params of your notice. Try this maybe help you: def A session[:notice] = "I came from ActionName A" redirect_to :action => B #that notice can be displayed only if you do render :action => B end def B flash[:notice] = session[:notice] end ~*~*~*~*~*~*~*~*~*~*~ Reinhart Ariando YM: Booking2Heaven WEB: teapoci.blogspot.com ~*~*~*~*~*~*~*~*~*~*~ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Really? I doubt it ! render :action => B means "Use action B''s view as this action''s view", not means "start a new request to B" and in this way you just change your default view, not a "next request" see this from http://api.rubyonrails.org/ " # Renders the template for the action "goal" within the current controller render :action => "goal" " " the flash is suppose to persist to the next request (but only the next request). If you set flash.now[:notice] = ... Then it won''t persist to the next request. " And as I said before, it''s true that the "redirect_to" request acts as "the next request", and do get the flash content. For this, use below for test: " def a flash[:a] = "I am a" #render :action => ''b'' redirect_to :action => ''b'' end def b if flash[:a].blank? flash[:a] = "I am b" end render :text => flash[:a] end " It seems "link_to" request ''s parent request, I mean the request which has a "link_to" tag, will act as "the next request" as I mentioned in the first reply Next request ? What actually does next request mean ? Can anyone give a precise definition? Can anyone give example-usage for flash ? On Feb 22, 9:59 am, Visit Indonesia 2008 <rails-mailing-l...@andreas- s.net> wrote:> You can not display that flash[:notice] on :action B because action B > doesnt have params of your notice. Try this maybe help you: > > def A > session[:notice] = "I came from ActionName A" > redirect_to :action => B > #that notice can be displayed only if you do render :action => B > end > > def B > flash[:notice] = session[:notice] > end > > ~*~*~*~*~*~*~*~*~*~*~ > > Reinhart Ariando > YM: Booking2Heaven > WEB: teapoci.blogspot.com > ~*~*~*~*~*~*~*~*~*~*~ > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Feb-22 03:53 UTC
Re: Does a request and the request created by a "link_to ''xx
redirect_to is the same like link_to in view, if your action ''A'' redirect to another action ''B'', all params in A are unreadable in ''B'' unless you including params behind of :action or store in in session. render what i mean is using all logics in def B but you will use A.rhtml to display all logics in B & A. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think you are wrong, at least in rails 2.0.2 render to B in action A means using only logics in A and B.rhtml just this. You can test this in rails 2.0.2 or read the api : http://api.rubyonrails.org/classes/ActionController/Base.html#M000452 I thought the same as you when I was using rails 1.8 or before. On Feb 22, 11:53 am, Visit Indonesia 2008 <rails-mailing-l...@andreas- s.net> wrote:> redirect_to is the same like link_to in view, if your action ''A'' > redirect to another action ''B'', all params in A are unreadable in ''B'' > unless you including params behind of :action or store in in session. > > render what i mean is using all logics in def B but you will use A.rhtml > to display all logics in B & A. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Feb-22 10:19 UTC
Re: Does a request and the request created by a "link_to ''xx
On 22 Feb 2008, at 01:59, Visit Indonesia 2008 wrote:> > You can not display that flash[:notice] on :action B because action B > doesnt have params of your notice. Try this maybe help you: >Um bollocks. the flash is actually stored in the session anyway, so the code below accomplishes nothing more than setting flash[:notice]. If you were to use render :action => B then you should use flash.now[:notice] = ''hello'', so that the flash does not persist to the request after (but in your view you still access it as flash[:notice] Fred> def A > session[:notice] = "I came from ActionName A" > redirect_to :action => B > #that notice can be displayed only if you do render :action => B > end > > def B > flash[:notice] = session[:notice] > end > > > ~*~*~*~*~*~*~*~*~*~*~ > > Reinhart Ariando > YM: Booking2Heaven > WEB: teapoci.blogspot.com > ~*~*~*~*~*~*~*~*~*~*~ > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---