Strange DoubleRenderError in Rails 3

I am trying to use the standard redirect_to some_path and return syntax, but for some reason Rails 3 doesn't like it.

 class MyController < ApplicationController def some_action redirect_to "http://www.google.com" return end end 

Gives me a standard error message:

 Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". 

It refers to the exact line of my redirect_to "http://www.google.com" in error. It is impossible to understand how this is possible!

I commented everything in front of the filters that I can find, no difference.

This is Rails 3.0.0

+4
source share
1 answer

Oh, man finally figured it out.

Where I put some_action above, I actually called the status method. Apparently, this is a reserved word or something on the rails, because it called it from another place - therefore, DoubleRender's error.

Wow - it took me a lot more time than I needed.

+8
source

All Articles