app/controllers/application_controller.rb
# Common auto_complete handler for all core controllers.
#----------------------------------------------------------------------------
Common auto_complete handler for all core controllers.
Common auto_complete handler for all core controllers .
def auto_complete
    @query = params[:auto_complete_query] || ''
    @auto_complete = hook(:auto_complete, self, :query => @query, :user => current_user)
    if @auto_complete.empty?
      exclude_ids = auto_complete_ids_to_exclude(params[:related])
      @auto_complete = klass.my.text_search(@query).search(:id_not_in => exclude_ids).result.limit(10)
    else
      @auto_complete = @auto_complete.last
    end
    session[:auto_complete] = controller_name.to_sym
    respond_to do |format|
      format.any(:js, :html)   { render :partial => 'auto_complete' }
      format.json { render :json => @auto_complete.inject({}){|h,a|
        h[a.id] = a.respond_to?(:full_name) ? a.full_name : a.name; h
      }}
    end
  end
def auto_complete @query = params [ :auto_complete_query ] || '' @auto_complete = hook ( :auto_complete , self , :query => @query , :user => current_user ) if @auto_complete . empty? exclude_ids = auto_complete_ids_to_exclude ( params [ :related ] ) @auto_complete = klass . my . text_search ( @query ) . search ( :id_not_in => exclude_ids ) . result . limit ( 10 ) else @auto_complete = @auto_complete . last end session [ :auto_complete ] = controller_name . to_sym respond_to do | format | format . any ( :js , :html ) { render :partial => 'auto_complete' } format . json { render :json => @auto_complete . inject ( { } ) { | h , a | h [ a . id ] = a . respond_to? ( :full_name ) ? a . full_name : a . name ; h } } end end
Common auto_complete handler for all core controllers.
Common auto_complete handler for all core controllers .