From 553c1396dd2ee5822ff968283bd2edf8b5c9d0ce Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 21 Sep 2015 15:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=88=9B=E5=BB=BA=E4=B8=8D?= =?UTF-8?q?=E6=88=90=E5=8A=9F=20=E7=BB=99=E5=87=BA=E5=8E=9F=E5=9B=A0=20?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=8F=91=E5=B8=83=E6=97=B6=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 11 ++------- app/controllers/memos_controller.rb | 37 ++++------------------------ app/views/forums/show.html.erb | 31 ++++++++++++++++++++--- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 415321655..be6543be2 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -7,7 +7,7 @@ class ForumsController < ApplicationController before_filter :find_forum_if_available before_filter :authenticate_user_edit, :only => [:edit, :update] before_filter :authenticate_user_destroy, :only => [:destroy] - before_filter :require_login, :only => [:new, :create,:show,:destroy,:update,:edit] + before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit] helper :sort include SortHelper @@ -164,14 +164,7 @@ class ForumsController < ApplicationController @memos @my_topic_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is null").count @my_replies_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is not null").count - # @offset, @limit = api_offset_and_limit({:limit => 10}) - # @forum = Forum.find(params[:id]) - # @memos_all = @forum.topics - # @topic_count = @memos_all.count - # @topic_pages = Paginator.new @topic_count, @limit, params['page'] - - # @offset ||= @topic_pages.offset - # @memos = @memos_all.offset(@offset).limit(@limit).all + @errors = params[:errors] respond_to do |format| format.js format.html { diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 9922aabbe..f7de712ca 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -73,41 +73,14 @@ class MemosController < ApplicationController end end #end - format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } - format.json { render json: @memo, status: :created, location: @memo } + format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } + format.json { render json: @memo, status: :created, location: @memo } else flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" - # back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id) - pre_count = REPLIES_PER_PAGE - - @memo_new = @memo.dup - @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 - unless @memo.new_record? - @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) - end - - - page = params[:page] - if params[:r] && page.nil? - offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count - page = 1 + offset / pre_count - else - - end - @reply_count = @memo.children.count - @reply_pages = Paginator.new @reply_count, pre_count, page - @replies = @memo.children. - includes(:author, :attachments). - reorder("#{Memo.table_name}.created_at DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all - if @memo.new_record? - format.html { render :new,:layout=>'base_forums'} - else - format.html { render action: :show } + format.js + format.html { redirect_to( forum_path(Forum.find(params[:forum_id]),:errors=>@memo.errors.full_messages[0])) } format.json { render json: @memo.errors, status: :unprocessable_entity } - end + #end end end diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index ee3679241..ad54f6bc0 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,3 +1,4 @@ +<%= javascript_include_tag 'new_user' %>