"You are being redirected" when switching controllers

Hey folks

I’ve got a couple of Actions that call methods in different controllers.
So for example I rewrite the URI from

/home

to

/login/login

However, when I do this Firefox displays a “You are being redirected”
message and IE simply dies.

Is there anyway round this or should I just avoid moving controllers
like this.

Cheers
Iain

I assume this means you’re doing something other than the norm:

redirect_to :controller => “login”, :action => “login”

or are you talking about

render :action => …

?

Jason

How are you doing the rewrite? I do this same practice all the
time. It’s pretty simple. In the action for home you check if they
need to login if they do, then use this snippet:
redirect_to :controller => “login”, :action => “login”

This causes a 302 status code with the correct target url.

Niels

I’d say do one of two things:

Get rid of the .htaccess redirect. You’re bypassing, and thus confusing,
Rails.

Move the Rails site to have it’s root at www.mysite.com:3500/home. This
seems like it would fit your situation better.

Jason

Hi folks.

Thanks for the replies. To explain the full problem. I run my site on
a shared host, I know it’s not ideal, but it is cheap. To achieve this
I have to run Mongrel using a different port from 80 as my hosting
company has Apache running on port 80. So the URI looks like this:

www.mysite.com:3500/home

I’ve set up a redirect in the .htaccess file so if a user types in
www.mysite.com they are forwarded to www.mysite.com:3500/home

And from what you are saying I’m wondering if the redirect is part of
the problem as I’ve set it up as a Permanent 302 redirect.

The problem comes when the user clicks the login button on the home
page, the login form code is as follows.

<% form_tag :controller => ‘login’, :action => ‘login’ do %>

The browser then writes the URI as www.mysite.com:3500/login/login and
that’s when I get the redirect error.

Annoyingly this doesn’t happen when I’m working from localhost

Any ideas greatfully received :slight_smile:

I’m having the same problem all of a sudden.

I’m using the following form:

redirect_to :action => "list"

Whenever it hits code like this I get a you are being re-directed
page, which doesn’t actually re-direct either.

I solved this problem by downgrading my rails version to 2.3.5.

To downgrade run command gem install -v=2.3.5 rails

I Hope soon it will be fixed in 2.3.8 version.

Iain wrote:

Hey folks

I’ve got a couple of Actions that call methods in different controllers.
So for example I rewrite the URI from

/home

to

/login/login

However, when I do this Firefox displays a “You are being redirected”
message and IE simply dies.

Is there anyway round this or should I just avoid moving controllers
like this.

Cheers
Iain

Iwan B. wrote:

Same problem (but with v. 2.3.8) and same solution (downgrade to 2.3.5).

(With glesys.se VPS, Ubuntu 8.04, monit+mongrel)

Thanks a lot!

Iwan

Got same problem on Rails 2.3.8, running FreeBSD 7.0, Mongrel 1.1.5
(using clusters). Downgrading to Rails 2.3.5 solved this problem. I
believe it’s a combination with mongrel since the same code works
flawlessly on passenger.

I also got errors (ActionController::InvalidAuthenticityToken). I tried
clearing cache, restarting server, … but nothing seemed to work.
Downgrading to 2.3.5 solved this issue as well.

Lenart

Nominerdene Purevjav wrote:

I solved this problem by downgrading my rails version to 2.3.5.

To downgrade run command gem install -v=2.3.5 rails

I Hope soon it will be fixed in 2.3.8 version.

Iain wrote:

Hey folks

I’ve got a couple of Actions that call methods in different controllers.
So for example I rewrite the URI from

Same problem (but with v. 2.3.8) and same solution (downgrade to 2.3.5).

(With glesys.se VPS, Ubuntu 8.04, monit+mongrel)

Thanks a lot!

Iwan