# Redirect problem

**URL:** <https://www.ruby-forum.com/t/redirect-problem/145344>\
**Category:** Rails\
**Created:** [August 8, 2008, 9:02am UTC](https://www.ruby-forum.com/t/redirect-problem/145344 "2008-08-08T09:02:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [August 8, 2008, 9:02am UTC](https://www.ruby-forum.com/t/redirect-problem/145344/1 "2008-08-08T09:02:45Z")

</div>

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?  
true  
else  
redirect\_to root\_path  
end  
end

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?

greets  
sigma

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [August 8, 2008, 9:07am UTC](https://www.ruby-forum.com/t/redirect-problem/145344/2 "2008-08-08T09:07:26Z")

</div>

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

cheers  
shuaib

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [August 8, 2008, 9:10am UTC](https://www.ruby-forum.com/t/redirect-problem/145344/3 "2008-08-08T09:10:56Z")

</div>

Ok, this would be a solution 😉

Thank you!
