diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 4c0d91884..0216d529d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -256,14 +256,14 @@ class TagsController < ApplicationController # 获取有某类对象的tag总数 def get_tags_size - @issues_tags_num = Issue.tag_counts.size - @projects_tags_num = Project.tag_counts.size - @users_tags_num = User.tag_counts.size - @bids_tags_num = Bid.tag_counts.size - forum_tags_num = Forum.tag_counts.size - attachment_tags_num = Attachment.tag_counts.size - @open_source_projects_num = OpenSourceProject.tag_counts.size - @contests_tags_num = Contest.tag_counts.size + @issues_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Issue").count + @projects_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Project").count + @users_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"User").count + @bids_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Bid").count + forum_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Forum").count + attachment_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Attachment").count + @open_source_projects_num = ActsAsTaggableOn::Tagging.where(taggable_type:"OpenSourceProject").count + @contests_tags_num = ActsAsTaggableOn::Tagging.where(taggable_type:"Contest").count return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num, forum_tags_num, attachment_tags_num, @contests_tags_num, @open_source_projects_num end diff --git a/db/migrate/20140701075839_add_tag_type_index_to_tagging.rb b/db/migrate/20140701075839_add_tag_type_index_to_tagging.rb new file mode 100644 index 000000000..11a5b4ef9 --- /dev/null +++ b/db/migrate/20140701075839_add_tag_type_index_to_tagging.rb @@ -0,0 +1,5 @@ +class AddTagTypeIndexToTagging < ActiveRecord::Migration + def change + add_index :taggings, :taggable_type + end +end