title: How do I check if a controller action is already redirecting?
body: <p>OK, as is often the case, I have a controller action in my app that is protected from unauthorized access by a before_filter. The only thing is that I need to redirect this action if another condition is true:</p>
  
  <pre><code>class Payment &lt; ApplicationController
    before_filter login_required
  
    def new
      redirect_to some_other_path if @order.is_free?
      @payment = Payment.new
    end
  end
  </code></pre>
  
  <p>In my testing, I check to make sure that the action is correctly protected, however, it is also the case that the @order.is_free statement is true. When this is the case, I get the following error:</p>
  
  <pre><code>`render_with_no_layout': Can only render or redirect once per action
  </code></pre>
  
  <p>Is there any way of checking to make sure I'm not already redirecting or to override an existing redirect?</p>