I’m having a little trouble trying to understand how autocomplete works.
This is namely because there are so many plugins out there and some are
outdated and many come with mixed instructions.
I’m using the standard plugin called auto_complete from David Heinemeier
Hansson.
Here’s what I have so far:
Teams controller
auto_complete_for :team, :name
def virtual_matchups
@teams = Team.find(:all, :conditions => [‘name LIKE ?’,
“%#{params[:search]}%”])
end
Created a custom method called virtual_matchups. The name of the model
is Team and the name of the team name field is name.
I created a custom view:
virtual_matchups.html.erb
Test Virtual Matchups
<%= text_field_with_auto_complete :team, :name %>I added the following to routes.rb:
map.auto_complete ‘:controller/:action’, :requirements => { :action =>
/auto_complete_for_\S+/ }, :conditions => { :method => :get }
…
I go to http://localhost:3000/teams/virtual_matchups
… I get:
Couldn’t find Team with ID=virtual_matchups
I go to http://localhost:3000/teams/virtual_matchups/1
… I get:
the text field box but when typing into it, it does nothing…
I could use some help with a step by step procedure on how to use auto
complete. If I can do it just one time, I’m sure I could figure it out.
However, I’ve been messing around with the regular version, a jquery
version, even the ryan bates railscast and “none of them” work…
However, all start right in the middle of something and never explain
how to use it step by step from the beginning. I can’t find a solid
tutorial on using the plugin.
Thanks.
Posted via http://www.ruby-forum.com/.