error saying “autocomplete method doesn't exist” with rails3-autocomplete gem

北城余情 提交于 2019-12-20 07:28:52

问题


In my rails application I am trying to use rails3-jquery-autocomplete gem. I included the following line in Gemfile. 'gem rails3-jquery-autocomplete' and gave bundle install and its listed in the gems.

My controller :

class ReleasesController < AuthorizedController
  # GET /releases
  # GET /releases.xml
    autocomplete :users, :name 

     def new 
    @release = Release.new
    @ic_ids = params[:ic_ids] ? params[:ic_ids] : []
     @testers = User.find_by_sql("select * from users where id in(select user_id from user_role_assignments where role_id in (select id from roles where name like 'Tester')) order by name").paginate(:page=>params[:page],:per_page=>30)   
   if params[:project_id]
      @release.project = Project.find(params[:project_id])
    end
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @release }
          end
  end

  end

routes file:

get 'releases/autocomplete_users_name'

view file:

= autocomplete_field_tag 'tester_name', '', users_autocomplete_user_name_path, :size => 75 

I am getting the error

undefined method `autocomplete' for #<ReleasesController:0xb731e2c0>

Please help me out here.

Thanks, Ramya.


回答1:


Did you run the generator ? rails generate autocomplete:install

And within controller it should be

 Class SomeController
 autocomplete :user, :name 
   def yourmethods
   end
 end   

Please look at the instructions here : https://github.com/crowdint/rails3-jquery-autocomplete



来源:https://stackoverflow.com/questions/8677904/error-saying-autocomplete-method-doesnt-exist-with-rails3-autocomplete-gem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!