Created
November 28, 2009 02:13
-
-
Save jhchabran/244340 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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