title: undefined method `order' for nil:NilClass on chained where
body: <p>This is THE STUPIDEST thing (or I'm just stupid) but I'm getting a no method error for 'order' when my chained 'where' method returns no results. </p>
  
  <p>Shouldn't this just return an empty array for @companies so that I can deal with that in my view?</p>
  
  <p>Controller:</p>
  
  <pre><code>@companies = Company.all.filter(domicile = params[:domicile], due_date = params[:due_date]).order("name ASC")
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>def self.filter(domicile, due_date)
    where( "domicile_id = ?", domicile ) if domicile.present?
    where("extract(month from due_date) = ?", due_date) if due_date.present?
    end
  </code></pre>
  
  <p>views/companies/index:</p>
  
  <pre><code>@companies.each do |c|
     = c.name
  - if @companies.empty?
    %p No companies were found.
  </code></pre>