I was wondering what the purpose of wrapping a redirect_to in a format.html block is. I get why you''d want to do this with a render, but if you''re redirecting the browser to another URL, what''s the point? As I understand it, when redirect_to is called, Rails sends a 302 back to the browser, so I''m having trouble understanding why format plays any part in this. No biggie, just need some clarification on what''s actually happening. Cheers, Ricky --~--~---------~--~----~------------~-------~--~----~ 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 28 Jan 2009, at 10:30, Ricky <ricky-Hm4eNWcjZEGtg43j4YVSCLpzq4S04n8Q@public.gmane.org> wrote:> > I was wondering what the purpose of wrapping a redirect_to in a > format.html block is. I get why you''d want to do this with a render, > but if you''re redirecting the browser to another URL, what''s the > point? As I understand it, when redirect_to is called, Rails sends a > 302 back to the browser,It might not be a browser. Eg with a create action you would typically redirect browsers to the show action, but the XML api probably wouldn''t do that. Fred> so I''m having trouble understanding why > format plays any part in this. No biggie, just need some clarification > on what''s actually happening. > > Cheers, > Ricky > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> It might not be a browser. Eg with a create action you would typically > redirect browsers to the show action, but the XML api probably > wouldn''t do that.Thanks for responding Fred. So are you saying that sometimes a redirect is not actually a redirect in the 302 sense of the word? Rather that, sometimes, a redirect *does* result in actual content being sent back to the browser/AJAX component? Rick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 28 Jan 2009, at 23:42, Ricky wrote:> >> It might not be a browser. Eg with a create action you would >> typically >> redirect browsers to the show action, but the XML api probably >> wouldn''t do that. > > Thanks for responding Fred. > > So are you saying that sometimes a redirect is not actually a redirect > in the 302 sense of the word? Rather that, sometimes, a redirect > *does* result in actual content being sent back to the browser/AJAX > component? >A redirect is always a redirect. What i''m saying is that sometimes you don''t want to redirect, in the aforementioned xml api example you''d probably just respond with an empty response with the appropriate http status code. An ajaxified interface is also a place where you might not want to do a redirect (you''d just return some html to be inserted into the DOM or produce some javascript to execute). Fred> Rick > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> A redirect is always a redirect. What i''m saying is that sometimes you > don''t want to redirect, in the aforementioned xml api example you''d > probably just respond with an empty response with the appropriate http > status code. An ajaxified interface is also a place where you might > not want to do a redirect (you''d just return some html to be inserted > into the DOM or produce some javascript to execute).What I wasn''t understanding was that the format.xxx methods were acting similarly to case statements. So the appropriate block of code is executed depending on what the mime format is. With that tiny tidbit of knowledge, it all becomes completely comprehensible. Rick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---