Browse files

statistics count read without scope.

  • Loading branch information...
1 parent 57d5a40 commit 93107a3b109419b140ae12d7f746f6c080063b21 @huacnlee huacnlee committed Apr 14, 2012
View
6 app/cells/topics/sidebar_statistics.zh-CN.html.erb
@@ -1,8 +1,8 @@
<div class="totals box">
<h2><%= t("common.statics")%></h2>
<ul>
- <li>社区会员: <%= User.count %> 人</li>
- <li>帖子数: <%= Topic.count %> 个</li>
- <li>回帖数: <%= Reply.count %> 条</li>
+ <li>社区会员: <%= @users_count %> 人</li>
+ <li>帖子数: <%= @topics_count %> 个</li>
+ <li>回帖数: <%= @replies_count %> 条</li>
</ul>
</div>
View
6 app/cells/topics/sidebar_statistics.zh-TW.html.erb
@@ -1,8 +1,8 @@
<div class="totals box">
<h2><%= t("common.statics")%></h2>
<ul>
- <li>社區會員: <%= User.count %> 人</li>
- <li>話題數: <%= Topic.count %> 个</li>
- <li>回應數: <%= Reply.count %> 条</li>
+ <li>社區會員: <%= @users_count %> 人</li>
+ <li>話題數: <%= @topics_count %> 个</li>
+ <li>回應數: <%= @replies_count %> 条</li>
</ul>
</div>
View
3 app/cells/topics_cell.rb
@@ -15,6 +15,9 @@ def index_sections
# 边栏的统计信息
cache :sidebar_statistics, :expires_in => 30.minutes
def sidebar_statistics
+ @users_count = User.unscoped.count
+ @topics_count = Topic.unscoped.count
+ @replies_count = Reply.unscoped.count
render
end
View
2 app/controllers/topics_controller.rb
@@ -8,7 +8,7 @@ class TopicsController < ApplicationController
before_filter :init_base_breadcrumb
def index
- @topics = Topic.last_actived.fields_for_list.limit(15).includes(:user)
+ @topics = Topic.last_actived.fields_for_list.limit(15).includes(:user).to_a
set_seo_meta("","#{Setting.app_name}#{t("menu.topics")}")
drop_breadcrumb(t("topics.hot_topic"))
#render :stream => true

0 comments on commit 93107a3

Please sign in to comment.