0
私は、railsのrails-jquery-autocompleteで自動補完を使ってテキスト入力フィールドを作成しようとしています。私はこのページの手順をステップバイステップで実行しようとしました:https://github.com/bigtunacan/rails-jquery-autocomplete、しかし、私は提案されたテキストを表示するために入力ファイルを得ることができませんでした。誰かが私が間違って行ったことを特定するために私を助けてくれますか?前もって感謝します。Rails 4:rails-jquery-autocompleteが提案を表示しない
次は私のコードの抜粋です:
コントローラー:
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
データベース:
create_table "ingredients", force: :cascade do |t|
t.string "name", limit: 255
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
コンソールにエラーはありますか? – hgsongra
'gem 'rails-jquery-autocomplete''の代わりに、トークンフィールドhttp://railscasts.com/episodes/258-token-fieldsを使うことができます。これは、統合と軽量化が非常に簡単です。 – hgsongra
application.jsにjquery、jquery_ujs、jquery-ui/autocomplete、autocomplete-railsが必要です。 https://github.com/bigtunacan/rails-jquery-autocomplete#rails-4-and-higher –