From cda9543849eb9e66d6a68a252758c02fed811a60 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 23 Dec 2013 09:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=9B=9E=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E8=B6=85=E8=BF=87=E4=B8=80=E9=A1=B5=EF=BC=8C=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=8A=A8=E6=80=81=E7=82=B9=E5=87=BB=E8=BF=87=E5=8E=BB?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=AE=9A=E4=BD=8D=EF=BC=8C=E9=94=9A=E7=82=B9?= =?UTF-8?q?=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 6 ++++++ app/models/memo.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 03ecd8235..30dca1c2a 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -60,6 +60,12 @@ class MemosController < ApplicationController @memo.update_attribute(:viewed_count, @memo.viewed_count.to_i + 1) 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. diff --git a/app/models/memo.rb b/app/models/memo.rb index 56dd3e99c..284d2ba1b 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -21,7 +21,7 @@ class Memo < ActiveRecord::Base :description => :content, :author => :author, :type => Proc.new {|o| o.parent_id.nil? ? 'Memo' : 'Reply'}, - :url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :anchor => "reply-#{o.id}"})} + :url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :r => o.id, :anchor => "reply-#{o.id}"})} acts_as_activity_provider :author_key => :author_id, :func => 'memos', :timestamp => 'created_at'