create tags page and made tag filter for projects
This commit is contained in:
parent
1e5aa0efff
commit
6e08b5cc85
10 changed files with 62 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue