Dev R
Dev R

Reputation: 1902

rails-3-jquery autocomplete not working with nested models

my autocomplete functionality using the gem https://github.com/crowdint/rails3-jquery-autocomplete is not working. When I try to work with autocomplete in isolation (only one model) it works.

Here is my controller :-

autocomplete :location, :name

Model :-

belongs_to :location

View :-

 = fields_for @event.location do |location|

    = location.autocomplete_field :name, autocomplete_location_name_events_path, :placeholder => "Enter the name of the location"

routes :-

resources :events do
    get :autocomplete_location_name, :on => :collection
end

application.js.cofee

#= require autocomplete-rails

I am not able to debug properly either as to know what exactly is the issue.

Upvotes: 0

Views: 326

Answers (1)

DadoCe
DadoCe

Reputation: 329

Try

Routes:

get 'events/autocomplete_location_name'

View:

fields_for :location do |location|
location.autocomplete_field :name, events_autocomplete_location_name, :placeholder => "Enter the name of the location"

Upvotes: 1

Related Questions