add tags autocomplete

This commit is contained in:
Aleksei Kvitinskii 2011-11-05 14:57:40 +02:00
parent 6323cdda68
commit 1e5aa0efff
6 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,15 @@
class TagsController < ApplicationController
def index
end
def autocomplete
tags = Project.tag_counts.limit 8
tags = tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank?
tags = tags.map {|t| t.name}
respond_to do |format|
format.json { render json: tags}
end
end
end