vjnan369
vjnan369

Reputation: 853

undefined local variable or method autocomplete path rails 4

I am using autocomplete gem to populate the data while entering the text. i followed autocomplete doc. In my routes i added

gem 'rails-jquery-autocomplete'

in downloads_controller

  autocomplete :downloads, :fund, :full => true

in application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require jquery-ui
//= require autocomplete-rails

in routes file

 resources :downloads do
  get :autocomplete_downloads_fund, :on => :collection
end

in view

<%autocomplete_field_tag 'fund', '', downloads_autocomplete_path, :size => 75%>

when i run this i get,

undefined local variable or method `downloads_autocomplete_path' for #<#

my rake routes

autocomplete_downloads_fund_downloads GET    /downloads/autocomplete_downloads_fund(.:format) downloads#autocomplete_downloads_fund
                        downloads GET       /downloads(.:format)                                downloads#index

here downloads is a table name and fund is the attribute name,

Download is the model name

can anyone help me..

Upvotes: 0

Views: 590

Answers (1)

RAJ
RAJ

Reputation: 9747

Update the link:

<%= autocomplete_field_tag 'fund', '', autocomplete_downloads_fund_downloads_path, :size => 75 %>

Check all available routes:

rake routes

Upvotes: 3

Related Questions