title: Is it possible in Rails to check whether a redirect or render had already been issued?
body: <p>Ruby 2.0.2, Rails 4.0.3, Sorcery 0.8.5</p>
  
  <p>I tried to issue a redirect in my code, only to receive the error message that a redirect or render had already been issued.  If that is the case, I'm happy to return.  However, if the method is called for any other reason, I'd like to check to see if a redirect or render had been issued and, if not, issue it.  The code is authentication based on Sorcery.  </p>
  
  <p>In the application controller, I have:</p>
  
  <pre><code>  def not_authenticated
      redirect_to login_url # , :alert =&gt; "First log in to view this page."
    end
  </code></pre>
  
  <p>This ends up checking for current_user, as follows:</p>
  
  <pre><code>  def current_user
      @current_user ||= @view.current_user unless @view.blank?
      begin
        @current_user ||= Associate.find(session[:user_id]) unless session[:user_id].blank?
      rescue ActiveRecord::RecordNotFound =&gt; e
        return
      end
      current_user = @current_user
    end
  </code></pre>
  
  <p>In the rescue, I'd like to determine whether or not a redirect or render had already occurred, so that I could redirect_to login_url if not.  This would mean, of course, that it was called from a different method, which it is.  Thanks.</p>