title: Always apply scopes computed for a complex scenario when retrieving objects in Rails
body: <p>I have several scopes that need to be applied for a complex scenario. But currently, I "store" this scenario in a method:</p>
  
  <pre><code>def search param1, param2
    results = Model.all
    if param1 == ...
      results = results.scope1
    else
      results = results.scope2
    end
    ...and so on...
  end
  </code></pre>
  
  <p>However, I would like to define this complex scenario directly on the model, so that when I do <code>Model.all</code> or <code>Model.where</code> or whatever, these scopes should be automatically added.</p>
  
  <p>But somehow, I also need to tweak the scenario with some parameters from the outside (see <code>param1</code> and <code>param2</code> from above).</p>
  
  <p>How can I achieve this? If it is not possible, what's the best of adding complex filtering on a model when searching for results?</p>