我正在尝试使用rails的rails-jquery-autocomplete创建一个带有自动完成功能的文本输入字段。我尝试按照此页面上的说明一步一步地执行:https://github.com/bigtunacan/rails-jquery-autocomplete,但我无法获取输入文件以显示任何建议的文本。有人可以帮我确定我做错了吗?提前谢谢。
以下是我的代码片段:
控制器:
SELECT PD.column_name1, PD.column_name2, PD.column_name3 FROM table_name WHERE PD.column_name1 = value1, PD.column_name2 = value2, PD.column_name3 = value3 AS PD (SELECT CASE
WHEN PD.column_name1 = value1 THEN "column_name1"
WHEN PD.column_name2 = value2 THEN "column_name2"
WHEN PD.column_name3 = value3 THEN "column_name3")
查看:
class LabController < ApplicationController
autocomplete :ingredient, :name
def index
@recipe = Recipe.where(station: "Laboratory")
end
end
路线:
.container
= autocomplete_field_tag 'test', '', autocomplete_ingredient_name_lab_index_path
数据库:
resources :lab, only: [:index, :show] do
get :autocomplete_ingredient_name, :on => :collection
end
答案 0 :(得分:0)
问题是溃败,你应该按照这些步骤进行操作
控制器:
class ArtistsController < ApplicationController
autocomplete :category, :name
end
查看:
<%= f.autocomplete_field :tag_list, autocomplete_category_name_artists_path %>
路线:
resources :artists do
get :autocomplete_category_name, on: :collection
end