A question about redirect_to

Hello guys, sorry for this very newbie question, but I don’t understand what’s happening.

I got a scaffolded model named User, it has an index action in his own controller (courtesy of “script/generate scaffold”). This action looks like this:

def index list render :action => ‘list’ end

So from here what I see this method does is:

  1. Call the list action to set a pair of variables (it’s not relevant here).
  2. Render the view for the list action.

The URL doesn’t change from http://localhost:3000/users to anything else, it stays the same.

My doubt is: Why something like this doesn’t work? def index redirect_to :list # I just want to go to the list action in case no action is specified. end

I thought that would just redirect me to the http://localhost:3000/users/list . But, I get the following error if I put the code above instead of what was there originally (look at first code sample): “stack level too deep”

Shouldn’t the redirect_to just take me to the right URL?

In this case if I type this: http://localhost:3000/clients

I would expect it to take me to: http://localhost:3000/clients/list

And since that isn’t the case I would appreciate if someone could explain to me how is it really working. :wink:

Best regards, Adrián.

your syntax of redirect_to was wrong, try this:

def index   redirect_to :action => "list" end

Adrián De la Cruz schrieb:

OMG, sorry for that :S