Action not found
Closed this issue · 2 comments
seajoshc commented
It seems like the creation of the autocomplete action in my controller is not happening for me and I'm not sure why. Using rails 3.2.16 and rails3-jquery-autocomplete 1.0.14.
AbstractController::ActionNotFound (The action 'autocomplete_service_name' could not be found for ScoresController):
application.js
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails
model
class Score < ActiveRecord::Base
attr_accessible :score, :service_name, :core, :manual_lock, :lock_comment
def self.search(search)
if search
where('service_name LIKE ?', "%#{search}%")
else
all
end # if
end # def search
end # class
controller
class ScoresController < ApplicationController
autocomplete :score, :service_name, :full => true
other code omitted...
routes
resources :scores do
get :autocomplete_service_name, :on => :collection
end
rake routes | grep autocomplete
autocomplete_service_name_scores GET /scores/autocomplete_service_name(.:format) scores#autocomplete_service_name
view
<%= autocomplete_field_tag 'service', '', autocomplete_service_name_scores_path %>
Any help would be appreciated.
bigtunacan commented
Notice from the documentation (README),
Controller
To set up the required action on your controller, all you have to do is call it with the class name and the method as in the following example:
class ProductsController < Admin::BaseController
autocomplete :brand, :name
end
This will create an action autocomplete_brand_name on your controller, don't forget to add it on your routes file.
resources :products do
get :autocomplete_brand_name, :on => :collection
end
Notice in the sample how the autocomplete route is marked with both :brand
and :name
Similarly, in your case you have autocomplete :score, :service_name, :full => true
From this you see that your route is setup incorrectly as
`get :autocomplete_service_name, :on => :collection`
rather it should look something like this
`get :autocomplete_score_service_name, :on => collection`
Hope this helps.
seajoshc commented
Doh, thanks for the quick reply. That fixed it!!