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
Here’s a simplified version of my code:
In my PagesController:
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
In my ApplicationController:
redirect_to login_url and return
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
Is there a way to check to see if require_member initiated a redirect
without setting a session / global flag?