1
我有一个邮政和一个标记模型(后来作为属性称为:name
)。使rails3-jquery-autocomplete与这些Post和Tag模型一起工作?
它们与has_and_belongs_to_many
有关。
的意见/职位/ _form.html.erb:
<%= f.label :tags %>
<%= autocomplete_field_tag :tags, params[:tags], autocomplete_tags_name_posts_path %>
的routes.rb:
resources :posts do
get :autocomplete_tags_name, :on => :collection
end
posts_controller.rb:
class PostsController < ApplicationController
before_filter :authenticate_user!, :except => [:show, :index]
autocomplete :tags, :name
没有任何反应,也没有错误。
我有点困惑是否使用:tags
或:tags_name
。如documentation所示。
(它们都产生约未定义的方法和变量错误)
的application.js:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails
任何建议,以解决这一问题?