title: Rails Scopes - I Don't Want Any Scope Added in Some Conditions
body: <p>I'm somewhat new to Rails and have been working with the scopes in Rails 3.2 . I like how the scope separates out the code from the controller.  But, when I'm building a query with scopes, I can't figure out how to <em>not</em> add a scope in certain situations.  See the example below...</p>
  
  <p>In my CarsController class</p>
  
  <pre><code>    if !params[:make_name].blank?  
          @cars = Car.by_make(params[:make_name]).find(:all, :group =&gt; "name")
      else      
          @cars = Car.all
  </code></pre>
  
  <p>In my Car model class.  The code is trying to say "If the make_name string is 'all', then <strong><em>don't</em></strong> add any conditionals on it, otherwise add a condition."  </p>
  
  <pre><code>def self.by_make(make_name_str)
      if make_name_str == "all"
          where("cars.id &gt; ?", 0)
      else
          make_id = Make.where(:name =&gt; make_name_str).first.id
          where(:make_id =&gt; make_id)
      end
  end
  </code></pre>
  
  <p>Obviously the case where the string is "all" looks very hacked and is what my question is about.  How do I write it to return nothing - basically, don't add any scope in this situation?</p>