My (long, I apologize) question is a follow-on to: How to add tagging with autocomplete to an existing model in Rails?
I am using acts-as-taggable-on
and rails3-jquery-autocomplete
, and trying to set up a system (much like Stack Overflow) where users begin to enter in a tag and suggestions appear in a drop-down box.
I am in the answers#new form and I want to see a list of tags that relate to questions. i.e. Imagine being on SO looking for new Rails questions to answer, and searching for ra
. Ruby-on-Rails
pops up, you click it, and you see a list of questions under RoR, any one of which you can answer.
These are the steps I've taken.
<%= 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.)autocomplete :question, :tags, :full => true
. I also tried autocomplete :tag, :name, :full => true
.acts_as_taggable_on :tags
.<%= form_tag new_answer_url, :method => "get" do %>
<%= autocomplete_field_tag "tag_list", 'tags', autocomplete_question_tags_answers_path %>
<% end %>
A simple autocomplete (no tagging) works (but it only works once per page load). With tagging, no success.
With lots of experimentation (and many hours) I am getting these problems:
NameError (unitialized constant Tag)
in server response to initial entry.I would greatly appreciate any help you are able to give. I have gone through a few tutorials step-by-step but no luck today.
I know it only answers one of your questions, but I was able to solve the "unitialized constant Tag" issue by explicitly specifying the class name in my controller:
autocomplete :tag, :name, :class_name => 'ActsAsTaggableOn::Tag'
It seems some of the changes to the acts_as_taggable_on library broke the underlying assumption that the Tag class exists.
Beyond that, I noticed some strange behavior myself when I didn't have my jquery-ui css correctly included on the page—have you verified that everything's getting linked in properly?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With