我已經按照提及的所有內容here。但是,它不起作用。我有question_controller。我正試圖想出自動完成搜索框。我已創建finders_controller.rb與我具有以下的代碼route_to_app /應用/控制器/ finders_controller.rbRails 3.2.16自動完成
class FindersController < ApplicationController
autocomplete :question, :question
end
在路線route_to_app /配置/ routes.rb中
resources :finders do
get :autocomplete_question_question, :on => :collection
end
在視圖部分route_to_app /app/views/questions/index.html.erb
<div class = "span-24 last box">
<%form_for @finder do |f|%>
<%= f.autocomplete_field :question_question, autocomplete_question_question_finders_path %>
<%end%>
</div><!--End span-24 box.-->`
代碼route_to_app /應用/視圖/發現者/ index.html.erb是空白的。
的javascrip文件看起來像route_to_app /應用/資產/ Java腳本/ application.js中
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require autocomplete-rails
我收到以下錯誤消息。我相信根本錯誤:
未定義的方法`MODEL_NAME」的NilClass:類 顯示C:/Sites/iHardie/app/views/questions/index.html.erb在行#8提出:
<div class = "span-24 last box">
<%form_for @finder do |f|%>
<%= f.autocomplete_field :question_question, autocomplete_question_question_finders_path %>
<%end%>
</div><!--End span-24 box.-->
有人可以幫忙嗎?我在這裏呆了一段時間。我會買一個漂亮的比薩或送一張好禮物卡給誰來幫助我解決問題。
這是問題數據庫的樣子:
create_table "questions", :force => true do |t|
t.string "question"
t.string "answer"
t.integer "product"
t.integer "priority"
t.integer "user"
t.string "type"
t.boolean "favorite"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false end
我正在按問題搜索問題數據庫。謝謝。理想情況下,我想將其放置在菜單欄中。 – takaloosingh
您可以添加您的問題模型的外觀副本嗎?你應該可以從你的schema.rb文件中抓取它。 – bigtunacan