I have a login controller and a link so I can login my app. I would like to have something to come back to the page where I clicked that link. So, when I click the link I go to the login page and after I would like to return to the page where I clicked the link. I have uses request_uri in other apps, but I need something different now and be able to use it all around the web. -- 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 -~----------~----~----~----~------~----~------~--~---
Hi John, On Fri, 2009-02-20 at 17:26 +0100, John Smith wrote:> I have a login controller and a link so I can login my app. > I would like to have something to come back to the page where I clicked > that link. So, when I click the link I go to the login page and after I > would like to return to the page where I clicked the link. > I have uses request_uri in other apps, but I need something different > now and be able to use it all around the web.Depending on the complexity of your authentication processing, you may be able to do something as simple as: redirect_to :back I''m not sure what you mean by ''need something different now'' wrt request_uri. An alternative to the above would be to capture the source of the request in your login controller method and store it in the session for future use. There are other alternatives, of course. Maybe if you say more about what you mean by ''be able to use it all around the web'' you''ll get some more helpful responses. Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 20, 2009, at 1:43 PM, bill walton wrote:> Hi John, > > On Fri, 2009-02-20 at 17:26 +0100, John Smith wrote: >> I have a login controller and a link so I can login my app. >> I would like to have something to come back to the page where I >> clicked >> that link. So, when I click the link I go to the login page and >> after I >> would like to return to the page where I clicked the link. >> I have uses request_uri in other apps, but I need something different >> now and be able to use it all around the web. > > Depending on the complexity of your authentication processing, you may > be able to do something as simple as: > > redirect_to :back > > I''m not sure what you mean by ''need something different now'' wrt > request_uri. An alternative to the above would be to capture the > source > of the request in your login controller method and store it in the > session for future use. > > There are other alternatives, of course. Maybe if you say more about > what you mean by ''be able to use it all around the web'' you''ll get > some > more helpful responses. > > Best regards, > BillNote that if you do use :back, you need to rescue RedirectBackError in case there is no HTTP_REFERER to go back to. It might be simpler to look at what redirect_to does with :back and do that yourself (exercise for the reader ;-) begin redirect_to :back rescue RedirectBackError redirect_to home_url # or something appropriate for your app. end -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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, but I can not do redirect_to :back, because it redirects to the login page. I''ll need something different. One possibility is to use a session variables for my controller and method, but the problem is that sometimes I need also and id, like ''posts/11''. I would like something more general. I would like to be able to save all the url in a session variable and then be able to redirect back to it. Is it possible? -- 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 -~----------~----~----~----~------~----~------~--~---
You''ll probably want to adopt an approach similar to restful- authetication''s method: def store_location session[:return_to] = request.request_uri end (call this from your action that shows users the login page - see http://github.com/technoweenie/restful-authentication/blob/5799593a28bb88e98b8cfe32d2f207c753a2bd9b/generators/authenticated/templates/authenticated_system.rb for details) --Matt Jones On Feb 24, 3:08 am, John Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks, but I can not do redirect_to :back, because it redirects to the > login page. I''ll need something different. One possibility is to use a > session variables for my controller and method, but the problem is that > sometimes I need also and id, like ''posts/11''. I would like something > more general. I would like to be able to save all the url in a session > variable and then be able to redirect back to it. Is it possible? > -- > 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 -~----------~----~----~----~------~----~------~--~---