title: HTTP Basic Auth for some (not all) controllers
body: <p>Using Rails 3.2.</p>
  
  <p>I have half a dozen controllers, and want to protect <strong>some</strong> (but not all) of them with <code>http_basic_authenticate_with</code>. </p>
  
  <p>I don't want to manually add <code>http_basic_authenticate_with</code> to each controller (I could add another controller in the future and forget to protect it!). It seems the answer is to put it in <code>application_controller.rb</code> with an <code>:except</code> arg which would list the controllers that should <em>not</em> be protected. The problem is, the :except clause wants method names rather than external controller module names, e.g.:</p>
  
  <pre><code>http_basic_authenticate_with :name =&gt; 'xxx', :password =&gt; 'yyy', :except =&gt; :foo, :bar
  </code></pre>
  
  <p>So then I thought "Wait, since I already have the protected controllers grouped in <code>routes.rb</code>, let's put it there." So I tried this in my routes:</p>
  
  <pre><code>  scope "/billing" do
      http_basic_authenticate_with :name ...
      resources :foo, :bar ...
    end
  </code></pre>
  
  <p>But now I get </p>
  
  <pre><code>undefined method `http_basic_authenticate_with'
  </code></pre>
  
  <p>What's the best way to approach this? </p>