0

Acts_as_taggable is working correctly. I did the following to add rails-jquery-autocomplete to my webapp. I am using Rails 4.2.2/Heroku in production.

add gem 'rails-jquery-autocomplete' to gem file
bundle install
heroku run bundle install

updated my application.js file to 

//= require jquery
//= require jquery_ujs
//= require jquery-ui/autocomplete
//= require autocomplete-rails
//= require bootstrap
//= require turbolinks
//= require_tree .

and pushed to Heroku

// Model
class Photo < ActiveRecord::Base
  acts_as_taggable_on :tags
end

// Controller
class PhotosController < ApplicationController
  autocomplete :tag, :name, :class_name => 'ActsAsTaggableOn::Tag'
  ...
private
  def photo_params
    params.require(:photo).permit(:picture, :title, :tag_list)
  end
end

// Routes
get 'tags/:tag', to: 'photos#index', as: :tag
resources :photos do
    get :autocomplete_tag_name, :on => :collection
end

//View  

<% form_for :photo, url: photos_path, html: {multipart: true } do |form| %>
  <%= f.file_field :picture %>
  <%= f.text_field :title %> 
  <%= form.label :tag_list, "Tags" %>
  <%= form.autocomplete_field :tag_list, autocomplete_tag_name_photos_path, :"data-delimiter" => ', ' %>
<% end %>

The form saves and the tags and photo are added to the database but the auto-complete does not work at all.

I have been through these topics but they have not helped me find the answer.

Community
  • 1
  • 1
Timmy Von Heiss
  • 2,160
  • 17
  • 39
  • Thank you for your nice post. I have success show the autocomplete tag, but have a problem when I go to click submit button, for create new or edit, it did nothing. And button seems change to disable style. On log, only show the last status from GET autocomplete. – Rizqi N. Assyaufi Dec 06 '19 at 08:01

1 Answers1

0

I forgot to add gem 'jquery-ui-rails'.

Timmy Von Heiss
  • 2,160
  • 17
  • 39