Skip to content

Instantly share code, notes, and snippets.

@jhchabran
Created November 28, 2009 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhchabran/244340 to your computer and use it in GitHub Desktop.
Save jhchabran/244340 to your computer and use it in GitHub Desktop.
# Autocomplete 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?
@auto_complete = self.controller_name.classify.constantize.my(:user => @current_user, :limit => 10).search(@query)
else
@auto_complete = @auto_complete.last
end
session[:auto_complete] = self.controller_name.to_sym
render :template => "common/auto_complete", :layout => nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment