I have a Contact Us link in the footer of most of my pages. Clicking this takes the user to a new page containing a form for sending us a msg of some sort. The form has Submit and Cancel buttons. After the user clicks one of these buttons to post the message, I''d like to return them to whatever page they were viewing before they clicked Contact Us. Anyway to do this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
lunaclaire wrote:> I have a Contact Us link in the footer of most of my pages. Clicking > this takes the user to a new page containing a form for sending us a > msg of some sort. > Anyway to do this?@request.env["HTTP_REFERER"] thing is, if the user got to the form from say, google, the http_referer would redirect back to the google search result page...a different option is to store the id of the page that was redirected to in the params, and redirect back to there when the post is submitted...params[:redirect] or something like that. whichever u choose. -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks, Shai. I like the second option since it seems more robust... but I''m missing what you mean by "store the id of the page"... what id would serve as the identifier in this case? On Jun 30, 11:51 pm, Shai Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> lunaclairewrote: > > I have a Contact Us link in the footer of most of my pages. Clicking > > this takes the user to a new page containing a form for sending us a > > msg of some sort. > > Anyway to do this? > > @request.env["HTTP_REFERER"] > > thing is, if the user got to the form from say, google, the http_referer > would redirect back to the google search result page...a different > option is to store the id of the page that was redirected to in the > params, and redirect back to there when the post is > submitted...params[:redirect] or something like that. > > whichever u choose. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
BTW - I tried using redirect :back which seems obvious and I think is quite similar to what Shai is suggesting, but all it does is return to the Contact Us form page any thoughts? On Jul 1, 11:45 am, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks, Shai. > > I like the second option since it seems more robust... but I''m missing > what you mean by "store the id of the page"... what id would serve as > the identifier in this case? > > On Jun 30, 11:51 pm, Shai Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > lunaclairewrote: > > > I have a Contact Us link in the footer of most of my pages. Clicking > > > this takes the user to a new page containing a form for sending us a > > > msg of some sort. > > > Anyway to do this? > > > @request.env["HTTP_REFERER"] > > > thing is, if the user got to the form from say, google, the http_referer > > would redirect back to the google search result page...a different > > option is to store the id of the page that was redirected to in the > > params, and redirect back to there when the post is > > submitted...params[:redirect] or something like that. > > > whichever u choose. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I usually do this by appending a :return_to => request.request_uri at the end of the link_to that links to the contact form. Then add a before filter that stuffs that parameter into the session, and use that session variable for the destination for the redirect after the form has been submitted. If you are using acts_as_authenticated, you already have the redirect_back_or_default method that makes this easy. The cancel button can also take a peek at this session variable to know what its destination should be. -- Benjamin Curtis http://www.bencurtis.com/ -- blog http://agilewebdevelopment.com/rails-ecommerce -- build e-commerce sites with Rails On Jun 30, 2007, at 11:21 PM, lunaclaire wrote:> > I have a Contact Us link in the footer of most of my pages. Clicking > this takes the user to a new page containing a form for sending us a > msg of some sort. > > The form has Submit and Cancel buttons. > > After the user clicks one of these buttons to post the message, I''d > like to return them to whatever page they were viewing before they > clicked Contact Us. > > Anyway to do this? > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---