title: Rails: Redirect to page if condition
body: <p>I want to redirect a user if a condition is true:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    @offline = 'true'
    redirect_to :root if @offline = 'true'
    protect_from_forgery
  end
  </code></pre>
  
  <p><strong>Edit</strong>
  This is what I'm trying now with no success. The default controller is not the Application Controller.</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
      before_filter :require_online 
  
      def countdown
  
      end
  
  private
    def require_online
      redirect_to :countdown
    end
  
  end
  </code></pre>
  
  <p>This gives a browser error <code>Too many redirects occurred trying to open “http://localhost:3000/countdown”. This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.</code></p>
  
  <p>If I add <code>&amp;&amp; return</code>, the action never gets called.</p>