create tags page and made tag filter for projects

This commit is contained in:
Aleksei Kvitinskii 2011-11-05 21:00:05 +02:00
parent 1e5aa0efff
commit 6e08b5cc85
10 changed files with 62 additions and 24 deletions

View file

@ -10,7 +10,9 @@ class ProjectsController < ApplicationController
before_filter :require_non_empty_project, :only => [:blob, :tree]
def index
@projects = current_user.projects.all
source = current_user.projects
source = source.tagged_with(params[:tag]) unless params[:tag].blank?
@projects = source.all
end
def new

View file

@ -1,15 +1,11 @@
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}
@tags = Project.tag_counts.order('count DESC')
@tags = @tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank?
respond_to do |format|
format.json { render json: tags}
format.html
format.json { render json: @tags.limit(8).map {|t| t.name}}
end
end
end