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.