title: Filters and chaining of them
body: <p>I have two filters that get checked for my Rails model called Items. If both filters are enabled, Ie: certain params are passed then it filters down the Items based on the first one and then should use the results of the first filter as the basis to filter from the second. But it doesn't like me calling .where on the instance variable of @items which is being passed to my view? Any thoughts?</p>
  
  <p>Error is :
      undefined method `where' for #</p>
  
  <p>Code:</p>
  
  <pre><code>@coasters = Coaster.all
  
      if params[:type]
        type = params[:type]
        if type == 'powered'
          @coasters = @coasters.where("style = ?", "powered")
        else
          @coasters = @coasters.where("material LIKE ?", params[:type])
        end
      end
  
      if params[:letters]
        letters = params[:letters]
        if letters == '#'
          @coasters = @coasters.all.select { |r| /^[0-9].*/ =~ r.name }
        else
          letters = letters.split('-')
          lettersLower = (letters[0]..letters[1]).to_a
          lettersUpper = (letters[0].upcase..letters[1].upcase).to_a
          letters = lettersLower.concat(lettersUpper)
          conditions = (letters.map{ |letter| " name ILIKE '#{letter}%' " }.join('OR'))
          @coasters = @coasters.where(conditions)
        end
      end
  </code></pre>