jQuery autocomplete docs state there should be two Models, the first being the model that you want to use for autocomplete, the second being the model that has the first Model (and is attached to your page). However, I don’t have the second model, just a Controller w/view that has form elements, one of them an autocomplete input of the first Model (Venue).
The docs say I should do
resources :parse do
get :autocomplete_venue_name, :on => :collection
end
But that won’t work since the controller ‘Parse’ doesn’t have a model. I tried making a static route but I need that :collection option. How can I work around this requirement?
EDIT:
Below is the code from the rails+jquery autocomplete plugin. Note that I have a ProductsController but I don’t have a Products model, so I can’t do the routes.rb setup:
class Brand < ActiveRecord::Base
end
MODEL TO SEARCH ON:
create_table :brand do |t|
t.column :name, :string
end
CONTROLLER WITH DESIRED AUTOCOMPLETE FORM:
class ProductsController < Admin::BaseController
autocomplete :brand, :name
end
ROUTES.RB
resources :products do
get :autocomplete_brand_name, :on => :collection
end
This approach works only if I have a Products model, which I do not. I have a Controller that is displaying a form w/autocomplete inputs.
I am using jquery multi auto complete plugin in which you can select one or multi auto
complete value and if there is no model then it will work e.g
$(document).ready(function() {
in my case @tags = Tag.all
But you can give any other values in controller action.Whose model is not exist
Like in controller
@tags = [“cute”,”beauty”,”amazing”]
The code i am using for multi Autocomplete is below.
But you should include some jquery auto complete js files from jquery.UI.Download files from there and include in project.
jquery.ui.core
jquery.ui.widget
jquery.ui.position
jquery.ui.autocomplete