when using paginate, ive notice things that i dont fully understand yet. for example one of my view calls an action in my controller, which then calls an action in my application.rb. this action in the application.rb uses if statements to determine which path to go down which then calls a redirect to another action in the application.rb to build my paginate object. but when i changed the redirect_to to just the action name, my paginate object breaks when clicking on page 2. -- 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2006-Nov-27 16:30 UTC
Re: when do you use redirect_to vs calling a method?
koloa wrote:> > when using paginate, ive notice things that i dont fully understand yet. > > for example one of my view calls an action in my controller, which then > calls an action in my application.rb. this action in the application.rb > uses if statements to determine which path to go down which then calls a > redirect to another action in the application.rb to build my paginate > object. > > but when i changed the redirect_to to just the action name, my paginate > object breaks when clicking on page 2.A call from one controller method to another simply executes the code in that method and returns. However if the path taken through that other method calls "render" to render a given template, this will prevent the default template of the originally-called action (the template named after the action the browser requested) from being rendered. On the other hand a call to redirect_to makes Rails tell the browser to retry its request at a different URL. So if you remove your redirect and just call another action you have to make sure the correct template is rendered, perhaps by an explicit call to render. But the browser URL will not now change to point to the different action. It''s unlikely you need a redirect to achieve what you want. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 mark for the explanation. appreciate the help. -- 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 -~----------~----~----~----~------~----~------~--~---