crowdint / rails3-jquery-autocomplete

An easy and unobtrusive way to use jQuery's autocomplete with Rails 3

Home Page:http://rubygems.org/gems/rails3-jquery-autocomplete

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autocomplete on the application controller

charlesdg opened this issue · comments

Hello all,

I have an autocomplete on a shared view in all the application.

For the moment , I add this line in the application_controller.rb

autocomplete :user, :name

and I need to add in the route, all the resources to get it work:

resources :home, :profile, :resources3, :resources4 do
    get :autocomplete_user_name, :on => :collection
  end

Is there any idea how I can create a route available for all the application without enumerate all the resources?

Thank you

It is not considered best practice to define it directly on the application_controller.rb; it would be better to create a sub class controller and then have the necessary controllers inherit from this.

Either way, I believe you can achieve what you want by adding this to your routes.rb

get autocomplete_user_name: 'application#autocomplete_user_name', on: :collection