My (long, I'm sorry) question is a continuation: How do I add auto-complete tagging to an existing model in Rails?
I use acts-as-taggable-on and rails3-jquery-autocomplete and try to set up a system (like a stack overflow) where users start to enter a tag and the sentences are displayed in a drop-down list.
purpose
I'm in the answer #new form, and I want to see a list of tags related to questions . For example, imagine you are on SO looking for new Rails questions to answer and search for ra . Ruby-on-Rails pops up, you click on it, and you see a list of questions in RoR, any of which you can answer.
These are the steps that I have taken.
- Both gemstones are set. Both seem to work on their own.
- Added
<%= javascript_include_tag "ui/jquery.ui.position", "ui/jquery.ui.autocomplete", "autocomplete-rails.js", "rails.js", "application.js" %> . (I already have jQuery, UI Core, and UI Effects.) - Answer controller: I added at the top
autocomplete :question, :tags, :full => true . I also tried autocomplete :tag, :name, :full => true . - Question.rb:
acts_as_taggable_on :tags . - View:
<%= form_tag new_answer_url, :method => "get" do %>
<%= autocomplete_field_tag "tag_list", 'tags', autocomplete_question_tags_answers_path %>
<% end %>
Simple autocomplete (without tags) works (but it only works once per page load). Noted with no success.
Problems
With a lot of experimentation (and many hours) I get the following problems:
- I get a
NameError (unitialized constant Tag) in the server response to the initial entry. - With a tagless implementation (to search for the simplest question text), I get a drop-down list in the JQuery autocomplete style, but my cursors cannot access the up / down options. I have to click their mouse. In addition, the dropdown does not disappear if I do not reload the page!
- After the server responds once to the results (only those that were not tagged, as I already mentioned), it no longer responds to keystrokes or changes to the text element.
I would really appreciate any help you can give. I went through several textbooks in stages, but today, no luck.
sscirrus
source share