Sha256: 1f2f8e5ca8e04d4dd70e090f8eb94f8b9ee5a98c4e3e6d6bbd8d5e914a56d69b
Contents?: true
Size: 373 Bytes
Versions: 5
Compression:
Stored size: 373 Bytes
Contents
module Admin class AutocompleteController < BaseController def list model_class = params[:model].camelize.constantize field_name = params[:field].to_sym entities = model_class.where("#{field_name} ilike ?", "%#{params[:q]}%").order(field_name) render :json => entities.map {|e| {:id => e.id, :name => e.send(field_name)}} end end end
Version data entries
5 entries across 5 versions & 1 rubygems