title: Skip before_filter in Rails
body: <p>Names and objects have been simplified for clarity's sake. The basic concept remains the same.</p>
  
  <p>I have three controllers: <code>dog</code>, <code>cat</code>, and <code>horse</code>.
  These controllers all inherit from the controller <code>animal</code>.
  In the controller <code>animal</code>, I have a before filter that authenticates a user as such:</p>
  
  <pre><code>before_filter :authenticate
  
  def authenticate
    authenticate_or_request_with_http_basic do |name, password|
      name == "foo" &amp;&amp; password == "bar"
    end
  end
  </code></pre>
  
  <p>In the <code>show</code> action of <code>dog</code>, I need to have open access to all users (skip the authentication).</p>
  
  <p>If I were to write the authentication separately for <code>dog</code>, I could do something like this:</p>
  
  <pre><code>before_filter :authenticate, :except =&gt; :show
  </code></pre>
  
  <p>But since <code>dog</code> inherits from <code>animal</code>, I do not have access to the controller-specific actions. Adding <code>:except =&gt; :show</code> in the <code>animal</code> controller will not only skip authentication for the <code>show</code> action of <code>dog</code>, but also that of <code>cat</code> and <code>horse</code>. This behaviour is not desired.</p>
  
  <p>How can I skip the authentication only for the <code>show</code> action of <code>dog</code> while still inheriting from <code>animal</code>?</p>