我已經安裝了rails3-jquery-autocomplete gem及其顯示在寶石列表中。 我已經生成了autocomplete-rails.js文件並將其包含在我的佈局中。 我正在嘗試在名稱字段上爲用戶表實現自動完成字段。 我收到一個錯誤說錯誤與rails3-jquery-autocomplete
"undefined local variable or method `autocomplete' for #<#<Class:0xb709ac24>:0xb7099a7c>"
請讓我知道我已經出了問題。
releases_controller.rb
class ReleasesController < AuthorizedController
# GET /releases
# GET /releases.xml
autocomplete :users, :name
def new
@release = Release.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @release }
end
end
我的視圖文件:
= form.autocomplete_field_tag 'tester_name', :data-autocomplete=>"releases_autocomplete_users_name_path"
我的路線文件:
get 'releases/autocomplete_users_name'
錯誤:
ActionView::Template::Error (undefined local variable or method `autocomplete' for #<#<Class:0xb71cc1d8>:0xb71caa90>):
37: -puts "testers=#{@testers}"
38: = form.label :tester_tokens, "Testers"
39: = form.text_field :tester_tokens
40: = autocomplete_field_tag 'tester_name', :data-autocomplete=>"releases_autocomplete_users_name_path"
41: - @testers.each do |tester|
42: %tr
43: %td=tester.name