title: Undefined method for nil:NilClass Issue
body: <p>I have a rails 4 application that uses sunspot. Here's my controller:</p>
  
  <pre><code>before_action :set_product_type
  
  def index
     if params[:search].present?
        @search = Product.search do
           fulltext params[:search]
           with(:product_type_id, @product_type.id)
        end
        @products = @search.results
     else
        @products = Product.all.where(:product_type_id =&gt; @product_type.id)
     end
  end
  
  private
  def set_product_type
    @product_type = Product_type.find(params[:product_type_id])
  end
  </code></pre>
  
  <p>and here's my model:</p>
  
  <pre><code>searchable do
    text :data
    integer :product_type_id
  end
  </code></pre>
  
  <p>when I use this, I get:</p>
  
  <pre><code>undefined method `id' for nil:NilClass
  </code></pre>
  
  <p>but when I make the with use a static value:</p>
  
  <pre><code>with(:product_type_id, 3)
  </code></pre>
  
  <p>it works fine.</p>
  
  <p>I thought it might be because the @product_type.id was null, but when I print out <code>@product_type.id</code> it is set to a value.</p>
  
  <p>Thanks for all help!</p>