title: Rails 3 default scope, scope with override
body: <p>I have a situation where the behavior of an existing app is changing and it's causing me a major headache.</p>
  
  <p>My app has Photos. Photos have a status: <code>"batch", "queue", or "complete"</code>. All the existing Photos in the app are "complete".</p>
  
  <p>99% of the time I need to only show complete photos, and in all of the existing codebase I need every call to Photos to be limited to only complete photos.</p>
  
  <p>However, in the screens related to uploading and classifying photos I need to be able to fairly easily override that default scope to show batched or queued photos.</p>
  
  <p>Like many others, I need to find a way to easily override the default scope in certain situations. I looked at these questions (<a href="https://stackoverflow.com/questions/2073419/overriding-default-scope-in-rails">1</a>, <a href="https://stackoverflow.com/questions/1834159/overriding-a-rails-default-scope">2</a>) and they don't seem to answer what I'm looking for.</p>
  
  <p>The code I wish worked is this:</p>
  
  <pre><code>class Photo &lt; ActiveRecord::Base
    ...
    default_scope where(:status=&gt;'complete')
    scope :batch, unscoped.where(:status=&gt;'batch')
    scope :queue, unscoped.where(:status=&gt;'queue')
    ...
  end
  </code></pre>
  
  <p>However, that doesn't work. I tried wrapping the scope methods in lambdas, and that didn't work either.</p>
  
  <p>I realize default_scope comes with baggage, but if I can't use it with overrides then I'm looking at adding <code>scope :complete ...</code> and having to comb through every call to photos in my existing app and add <code>.complete</code> in order to filter unprocessed photos.</p>
  
  <p>How would you solve this problem?</p>