I'm a n00b with Rails, and I'm trying to implement basic autocomplete
according
to Agile Web Dev w/Rails 3rd edition (p. 584-586)
I've installed the auto_complete plugin, added the statement
"auto_complete_for :game, :publisher" to my controller (Game is the
model, publisher the field I want autocompletion on),
and and put the following in my view template:
Hi... I've been working on a gem recently that allows you to generate
scaffolding for auto_complete behavior, among other things. The idea
was to make it easier to get started with using a plugin like
auto_complete.
Based on your error messages, it looks like you may not have installed
the auto_complete plugin properly. You should also be using a macro/
helper called "text_field_with_auto_complete", and not
"auto_complete_field". Not sure how old your book is.
My article has a step-by-step example that hopefully will be
helpful... - pat
Pat, your view_mapper is very cool - worked like a charm, but
even after re-installing the auto_complete plugin (/vendor/plugins/)
and generating the view scaffolding, I'm still getting the undefined
method error:
undefined method `auto_complete_for' for GamesController:Class
in my controller.
I'm using Ruby 1.8.6, Rails 2.3.3
According to everyone's responses and what I've found searching for
answers, this should work but
it doesn't in my environment...
I'm happy to try to help you debug this one... if you want TAR up some/
all of the code and email it to me: pat@patshaughnessy.net
... however, I expect if I do run your code on my machine it will work
no problem. My guess is there's some environment issue you have.
The first thing I would try is to put a "puts" statement in the vendor/
plugins/auto_complete/init.rb file. The only explanation for
"auto_complete_for" not being defined is for some reason if the plugin
isn't being loaded when the Rails environment is initialized as your
app is started. You should see a messaged displayed in the console/log
when init.rb is loaded for your copy of auto_complete.
The second thing I would do is create a brand new, vanilla rails app,
install the auto_complete plugin into it and then create an
auto_complete form and see if it's works for you. You can follow the
step by step instructions in my "auto complete scaffolding" article I
linked to above. If it works, then there is some weird code issue in
your app; if it doesn't you have an environment problem on your
machine. (not sure what it could be)