Reputation: 969
I'm using the rails-jquery-autocomplete gem for an rfq model to search customers. The autocomplete search works fine when I'm creating a new rfq, but I get this error when I try to use the search while editing a record.
ActionController::RoutingError (No route matches [GET] "/rfqs/1/autocomplete_customer_name"):
I know what the error means but I'm not familiar enough with the routing to fix it.
Thank you ahead of time for the help
resources :rfqs do
get :autocomplete_customer_name, :on => :collection
member do
put :toggle
end
end
resources :customers do
get :autocomplete_company_name, :on => :collection
end
resources :companies
Upvotes: 0
Views: 237
Reputation: 4015
You need a member route for this to work (since you are trying to access "/rfqs/1/autocomplete_customer_name"):
get :autocomplete_customer_name, :on => :member
Member routes add an :id param in the route, while the collection routes work without id params:
resources :items do
get :foo, on: :member
get :bar, on: :collection
end
# will create folowing routes:
# items/:id/foo
# items/bar
Upvotes: 1