auto_complete plugin error: Couldn't find Question with ID=auto_complete_for_...
Posted
by bgadoci
on Stack Overflow
See other posts from Stack Overflow
or by bgadoci
Published on 2010-05-31T20:34:44Z
Indexed on
2010/05/31
21:03 UTC
Read the original article
Hit count: 155
I have successfully set up this plugin before so I am curious as to what I am doing wrong here. I have built the ability for users to add tags to questions. I am not using tagging plugin here but that shouldn't matter for this.
With respect to the auto complete, I am trying to have the form located in the /views/questions/show.html.erb
file access the Tags table and display entries in the tags.tags_name
column.
When I begin to type in the field I get the following error message:
Processing QuestionsController#show (for 127.0.0.1 at 2010-05-31 15:22:20) [GET]
Parameters: {"tag"=>{"tag_name"=>"a"}, "id"=>"auto_complete_for_tag_tag_name"}
Question Load (0.1ms) SELECT * FROM "questions" WHERE ("questions"."id" = 0)
ActiveRecord::RecordNotFound (Couldn't find Question with ID=auto_complete_for_tag_tag_name):
app/controllers/application_controller.rb:15:in `init_data'
For some reason I am actually passing the field name as the Question.id.
The plugin set up is fairly simple as you add the following line to your controller:
auto_complete_for :tag, :tag_name
and the following line in your routes.rb
file:
map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get }
I have added the controller line to both my tags and questions controller and also mapped resources for both tags and questions in my routes.rb file:
map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get }
map.resources :questions, :collection => {:auto_complete_for_tag_tag_name => :get }
I have played around with removing either or of the above but can't seem to fix it. Any ideas what I am doing wrong here?
UPDATE:
My QuestionsController#show action is fishing posts by:
@question = Question.find(params[:id])
© Stack Overflow or respective owner