Render works fine but redirect_to does not

Hello,
I have an application where I am getting an odd error. If I do
redirect_to url I get a DoubleRenderError. If I change that
redirect_to url to a render :text => url. The action works fine.

Why would I receive this error just by changing the way rails is
responding?

Regards,
Devin

On Wed, Apr 6, 2011 at 4:30 PM, Devin M [email protected] wrote:

Hello,
I have an application where I am getting an odd error. If I do
redirect_to url I get a DoubleRenderError. If I change that
redirect_to url to a render :text => url. The action works fine.

Why would I receive this error just by changing the way rails is
responding?

The error is telling you that you are using redirect/render twice in the
same action. Please post the controller code that is giving you the
error so
the group can better help you find the source of your error.

B.

Heres the error:

AbstractController::DoubleRenderError in
FoursquareController#authenticate
app/controllers/foursquare_controller.rb:10:in location' app/controllers/foursquare_controller.rb:33:in authenticate’

And the code:

def location
session[:geolat] = params[:geolat]
session[:geolong] = params[:geolong]
render :nothing => true
end
def authenticate
redirect_to “Log in?
client_id=#{FOURSQUARE_OAUTH_CONFIG[:client_id]}
&response_type=code&redirect_uri=#{FOURSQUARE_OAUTH_CONFIG[:redirect_uri]}”
end

Why does it even call location when thats not even mentioned the
action being called?
I only get this error if i change authenticate to have redirect_to

Sent from my iPhone

On Apr 6, 2011, at 9:38 PM, Devin M [email protected] wrote:

session[:geolat] = params[:geolat]
action being called?
I only get this error if i change authenticate to have redirect_to

Hit send before I meant to. It looks like, from the error message, that
from your render action in location you are calling authenticate which
then tries to redirect before the render from location is complete. This
is a no no. It works when you switch it to render_to because that is a
acting like a nested render which is ok. You might want to rethink how
you want to do that authentication if you really need that redirect.

B.

Sent from my iPhone

On Apr 6, 2011, at 9:38 PM, Devin M [email protected] wrote:

session[:geolat] = params[:geolat]
action being called?
I only get this error if i change authenticate to have redirect_to

From the error message it appears you are calling authenticate from what
is being rendered on a location call.