title: Sunspot/Solr : Searching with multiple fields
body: <p>What is the way to use Sunspot/Solr with mutiple fields ?
  It works fine with a simple form, as explained in this screencast : <a href="http://railscasts.com/episodes/278-search-with-sunspot" rel="nofollow">http://railscasts.com/episodes/278-search-with-sunspot</a></p>
  
  <p>You can see my draft which doesn't work : </p>
  
  <p><em>product.rb</em></p>
  
  <pre><code>searchable do
    text :address
    text :model
    text :category
  end
  </code></pre>
  
  <p>*products_controller.rb*</p>
  
  <pre><code>  def search
      @search = Sunspot.search(Product) do
        fulltext params[:address]
          with(:model, params[:model]) if params[:model].present?
          with(:category, params[:category]) if params[:category].present?
      end
      @products = @search.results
    end
  </code></pre>
  
  <p><em>products/search.html.erb</em></p>
  
  <pre><code>  &lt;%= form_tag products_search_path, :method =&gt; :get do %&gt;
      &lt;div class="field"&gt;
          &lt;%= label_tag "Address ?" %&gt;
          &lt;%= select_tag :address, "&lt;option&gt;he&lt;/option&gt;&lt;option&gt;ho&lt;/option&gt;".html_safe %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
          &lt;%= label_tag "Model ?" %&gt;
          &lt;%= text_field_tag :model, params[:model] %&gt;
          &lt;%#= select_tag :model, "&lt;option&gt;hi&lt;/option&gt;&lt;option&gt;ha&lt;/option&gt;".html_safe %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
          &lt;%= label_tag "Category ?" %&gt;
          &lt;%= text_field_tag :category, params[:category] %&gt;
      &lt;/div&gt;
      &lt;div id="buttonSearch"&gt;&lt;%= submit_tag "Search" %&gt;&lt;/div&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p><strong>The error :</strong></p>
  
  <pre><code>Sunspot::UnrecognizedFieldError (No field configured for Product with name 'model'):
    app/controllers/products_controller.rb:99:in `block in search'
    app/controllers/products_controller.rb:97:in `search'
  </code></pre>
  
  <p>Thanks guys for your helping!</p>