Ok, I think I understand why RoR will flag an attempt double render in an action. What I don''t understand is the philosophy of render and redirect_to. Specifically, why isn''t a return implicit in both those methods? Or, I guess, more to the point ... what are the advantages of writing code in the action after a render/redirect_to? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
There isn''t much point in writing code after a render/redirect in a controller method, and it''s safe to say it''s a best practice not to. I think the main reason render/redirect work the way they do is to make it easier to use those methods in before/after_filters. For what it''s worth, Merb''s render/redirect implementation is what you suggest here. On Mon, Feb 8, 2010 at 14:04, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Ok, I think I understand why RoR will flag an attempt double render in > an action. > > What I don''t understand is the philosophy of render and redirect_to. > > Specifically, why isn''t a return implicit in both those methods? > > Or, I guess, more to the point ... what are the advantages of writing > code in the action after a render/redirect_to? > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9/2/2010 3:04 AM, Ralph Shnelvar wrote:> Ok, I think I understand why RoR will flag an attempt double render in > an action. > > What I don''t understand is the philosophy of render and redirect_to. > > Specifically, why isn''t a return implicit in both those methods? > > Or, I guess, more to the point ... what are the advantages of writing > code in the action after a render/redirect_to? >I''m not sure how Rails works, but in a C++ HTTP server that we did, we could do something like write the response to the browser and then do the remaining house-keeping tasks. For example, it would be perfectly fine to update the logs, perform some other calculation, etc. that does not affect the output (since it''s been sent off already) but is something that the system could use. In another system, we did something like receive a request by HTTP POST, check the parameters and acknowledge the receipt of the request to the client as the response. Thereafter, we needed to process the request (which took quite a while) and then we would POST the results to a URL on the client''s side. I think both these cases would be things that don''t need to be put into an after_filter and would benefit from writing code in the action after a render (assuming Rails works/ allows one to work this way). Cheers, Mohit. 9/2/2010 | 3:26 AM. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 8, 2:04 pm, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Ok, I think I understand why RoR will flag an attempt double render in > an action. > > What I don''t understand is the philosophy of render and redirect_to. > > Specifically, why isn''t a return implicit in both those methods?Unless I''ve completely missed something, there isn''t a straightforward way to issue a nonlocal return in Ruby - which you''d need in order to make calling ''render'' return from the controller action. One could, of course, hack up something involving raise/rescue, but that''s going to be messy. --Matt Jones -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.