I just want to get some feedback and understanding on what the differences are between render and redirect_to. redirect_to post the info to the page you are redirecting to and redner simple does not post, correct? Thanks, ~S -- 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Jul-23 14:56 UTC
Re: redner and redirect_to
Hi -- On Mon, 23 Jul 2007, Shandy Nantz wrote:> > I just want to get some feedback and understanding on what the > differences are between render and redirect_to. redirect_to post the > info to the page you are redirecting to and redner simple does not post, > correct? Thanks,It''s easiest to understand if you consider that every action contains an implicit render command: def show @item = Item.find(params[:id]) # render the template show.rhtml end So when you do: def show @item = Item.find(params[:id]) render :template => "showme" # alternate template end or: def show render :text => "No showing today!" end you''re just completing this request in a non-default way. redirect_to, on the other hand, issues a whole new request. The whole request/response cycle starts again from the beginning: a new action, new instance variables, etc. Here''s an analogy (please ignore if unhelpful :-) Every day you put on a shirt. You might have a default shirt for each day -- but sometimes you might wear a non-default shirt for a given day. Putting on a shirt is like rendering a view. redirect_to is like it''s a whole new day. The process has started again from the beginning. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
That makes perfect sense and explains why when I was trying to retreive data from the parameters hash that nothing was there. I''m new to RoR and it seems like every now and then I discover a little quark that throws me for a loop. Your book, by the way, was one of the books that I read to learn RoR - very well written. Thanks again, ~S -- 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 -~----------~----~----~----~------~----~------~--~---