# Detecting if a render or redirect\_to has been called

**URL:** <https://www.ruby-forum.com/t/detecting-if-a-render-or-redirect-to-has-been-called/174024>\
**Category:** Rails\
**Created:** [August 19, 2009, 4:24pm UTC](https://www.ruby-forum.com/t/detecting-if-a-render-or-redirect-to-has-been-called/174024 "2009-08-19T16:24:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 19, 2009, 4:24pm UTC](https://www.ruby-forum.com/t/detecting-if-a-render-or-redirect-to-has-been-called/174024/1 "2009-08-19T16:24:43Z")

</div>

I know that you can only render / redirect\_to once in a controller  
action, but I was wondering if there’s a property I can check to see if  
a render / redirect\_to has been called. For example, I have a method I  
call to check access to a page, but I can’t do it in a filter because  
the page needs to be loaded first in order to check the permissions.  
(I’m writing a CMS and the pages are loaded dynamically based on the URL  
passed in)

Here’s a simplified version of my code:

In my PagesController:

def index

# See if page is member’s only

require\_member if @page.private?

# if not, redirect to the proper page

redirect\_to pages\_url(@page) and return

end

In my ApplicationController:

def require\_member  
unless current\_member  
store\_location  
redirect\_to login\_url and return  
end  
end

The issue is that because require\_member is in my application controller  
(so it can be used by other controllers) the “and return” is returning  
execution back to the calling method instead of actually ending  
execution.

Is there a way to check to see if require\_member initiated a redirect  
without setting a session / global flag?

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 19, 2009, 4:47pm UTC](https://www.ruby-forum.com/t/detecting-if-a-render-or-redirect-to-has-been-called/174024/2 "2009-08-19T16:47:51Z")

</div>

ACK! This actually worked as expected, the DoubleRenderError was being  
caused by something else.

Sorry!
