I believe I found a partial answer:
In my teams controller I placed:
class TeamsController < ApplicationController skip_before_filter :verify_authenticity_token, :only => [:auto_complete_for_team_name]
def auto_complete_for_team_name() team_name = params[:team][:name] @teams = Team.find(:all, :conditions => ['name LIKE ?', "%" + team_name + "%"]) render :partial => 'teamname' end
def virtual_matchups end
In my virtual_matchups.html.erb file I placed as a test:
<h1> Test Virtual Matchups </h1> <%= text_field_with_auto_complete :team, :name ,{}, :skip_style => false %>
I created a partial for teamname:
<ul> <% for team in @teams do %> <li> <div> <%=h team.name %> </div> </li> <% end %> </ul>
In my routing file I placed:
map.virtual_matchups '/virtual_matchups', :controller => 'teams', :action => 'virtual_matchups'
I restarted the server and the autocomplete works for this page, but I haven't tried it with a form.
My thoughts on this are it was very cumbersome to get it to work. I had to go through several different sites, put together all the pieces of the puzzle before it finally worked.
I have no idea why I had to use the skip_before_filter but without it, it would not autocomplete.
Can someone please look over the fixes I provided and if you have knowledge of autocomplete let me know if there is a simpler way of getting it to work, and/or what I need to do to polish up the code I created thus far to get it to work?
I will need two fields and a submit button that performs a query to the same controller but to a different action that will render a completely different partial containing information.
Many thanks in advance.