Sha256: e8a2af3aee9d470f916e46d5442afe075a54c94552d477dbd1379904f794d595
Contents?: true
Size: 794 Bytes
Versions: 3
Compression:
Stored size: 794 Bytes
Contents
class AutocompleteController < ApplicationController def index respond_to do |format| format.json { render :json => autocomplete_results } end end private def autocomplete_results query_term.present? ? model.autocomplete_results(query_term) : [] end def model params[:model].classify.constantize end def query_param_name if aa_associations_config.autocomplete_query_term_param_names.present? aa_associations_config.autocomplete_query_term_param_names.detect do |param_name| params.keys.map(&:to_sym).include?(param_name.to_sym) end else :q end end def query_term params[query_param_name] end def aa_associations_config Rails.application.config.aa_associations end end
Version data entries
3 entries across 3 versions & 1 rubygems