I am using the Crowdint rails3 jquery autocomplete and having trouble with my search form.
This is how my search
form looks without autocomplete:
<%= form_tag search_path, :method => 'get' do %> <%= text_field_tag :search, params[:search], :placeholder => "Search for a Product.....", :id => "main-search-field" %> <%= submit_tag "Search", :name => nil, :id => "main-search-field-button" %> <%end%>
Now when I change around the form for autocomplete and search:
<%= form_tag search_path, :method => 'get' do %> <%= autocomplete_field_tag 'name','', search_autocomplete_product_name_path, params[:search], :placeholder => "Search for a Product.....", :id => "main-search-field" %> <%= submit_tag "Search", :name => nil, :id => "main-search-field-button" %> <%end%>
This will not work if I have params[:search]
inside of my autocomplete_field_tag
:
ActionView::Template::Error (wrong number of arguments (5 for 4))
How do I set the search parameter so I can actually search with autocomplete?
More info:
class SearchController < ApplicationController autocomplete :product, :name, :full => true # Sunspot search. def index @search = Product.search do fulltext params[:search] paginate(:per_page => 1, :page => params[:page]) end @products = @search.results end end # routes.rb get 'search/autocomplete_product_name' resources :search, :only => [:index]