From 6fcf80cd3c2a29e2a56313e4a95f4849f8448519 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Dec 2016 20:31:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=9F=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 4 ++-- app/views/memos/_my_count_message.html.erb | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index fa295f0e0..06ea33c09 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -132,8 +132,8 @@ class MemosController < ApplicationController @memo_new = Memo.new - @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count - @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count + @my_topic_count = 0 + @my_replies_count = Memo.where(:parent_id => @memo.id).count respond_to do |format| format.js diff --git a/app/views/memos/_my_count_message.html.erb b/app/views/memos/_my_count_message.html.erb index e01ebfe18..851c66563 100644 --- a/app/views/memos/_my_count_message.html.erb +++ b/app/views/memos/_my_count_message.html.erb @@ -7,7 +7,11 @@ <% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
吧主:
<%= user_name %> -
回答:<%= @my_replies_count %> 帖子:<%= @my_topic_count %>
+
回答:<%= @my_replies_count %> + <% unless @my_topic_count == 0 %> + 帖子:<%= @my_topic_count %> + <% end %> +
@@ -22,18 +26,7 @@ <% end %>
- - - - - - - - - - - - + <% if @forum.creator.id == User.current.id %> <%= link_to "编辑贴吧", edit_forum_path(@forum), :class => "linkGrey3", :remote => true %>