From 134bdcebf23a7f60e2d1c2252fa06391bbe066dc Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 29 Dec 2016 16:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=90=A7=20index=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 4 +- app/views/forums/_my_count_message.html.erb | 12 +++--- app/views/forums/index.html.erb | 47 +++++---------------- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 75153c6de..5a5655ad0 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -121,8 +121,8 @@ class ForumsController < ApplicationController preload(:author, {:last_reply => :author}). all @forums = Forum.includes(:memos).preload(:topics) - @my_topic_count = Memo.where("author_id = #{User.current.id} and parent_id is null").count - @my_replies_count = Memo.where("author_id = #{User.current.id} and parent_id is not null").count + @my_forums_count = Forum.where(:creator_id => User.current.id).count + @my_memos_count = Memo.where(:author_id => User.current.id).count @errors = params[:errors] respond_to do |format| format.js diff --git a/app/views/forums/_my_count_message.html.erb b/app/views/forums/_my_count_message.html.erb index dfb9a5b12..ce0053cd2 100644 --- a/app/views/forums/_my_count_message.html.erb +++ b/app/views/forums/_my_count_message.html.erb @@ -1,16 +1,16 @@
-
<%= link_to image_tag(url_to_avatar(User.current), :width => 50, :height => 50, :alt=>'贴吧图像'), user_path(User.current) %>
-
-
我在贴吧
+
<%= link_to image_tag(url_to_avatar(User.current), :width => 50, :height => 50,:alt=>'贴吧图像' ), user_path( User.current) %>
+
-
\ No newline at end of file +
diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 67cee80af..a3d06f78a 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -10,56 +10,29 @@
综合
<%= link_to "发布新帖", new_forum_path(@forum), :class => "c_white db creatPostIcon bBlue", :remote => true %> -
<%= render :partial => 'show_topics',:locals => {:memos => @memos} %>
- - - - - - - - - - - -
-
<%= link_to image_tag(url_to_avatar(User.current), :width => 50, :height => 50,:alt=>'贴吧图像' ), user_path( User.current) %>
-
-
我在贴吧
- -
-
-
<%= @my_topic_count %>
-
发帖
-
+<%= render :partial => "my_count_message" %> + +
+
+

问吧

+ <%= link_to "新建贴吧", new_forum_path, :class => "btn-blue btn fr mt5 mr5", :remote => true %>
-
-
- -
-
-

问吧

- <%= link_to "新建贴吧", new_forum_path, :class => "btn-blue btn fr mt5 mr5", :remote => true %> -
-
+
<%= render :partial => "forums/right_bar" %> <% if @forums.count > 10 %> - 点击展开更多 + 点击展开更多 <% end %> -
+