Redirect problem

Hi all

I’ve got the following problem:
With this method i check if a user is logged in. If not, he will be
redirected to home:
def check_login
if logged_in?
redirect_to root_path

Now the problem is: When i call this method in an other method where
is a next redirect_to or a render-command, the error “Can only render
or redirect once per action” occures.

Is there something like the “die()”-Command in PHP for stopping the
execution-process after the first redirect?

Anyone an idea?


as far as i concern, double redirection is not allowed in rails. We
usually check the login method in before_filter and we do not call it
from within another method. So, I believe if u user before_filter, the
problem will fly


Ok, this would be a solution :wink:

Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs