From 404568be894ad2c825a3e9a19269a34b83838a2b Mon Sep 17 00:00:00 2001 From: yanxd Date: Sat, 22 Mar 2014 09:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=99=E8=A8=80url=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=95=99=E8=A8=80=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E7=9A=84url=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 9 ++++++++- app/models/journals_for_message.rb | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9492bfba..db47319e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -296,10 +296,17 @@ class ProjectsController < ApplicationController #Ended by young def feedback + page = params[:page] + # Find the page of the requested reply @jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') @limit = 10 + if params[:r] && page.nil? + offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) + page = 1 + offset / @limit + end + @feedback_count = @jours.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @feedback_pages = Paginator.new @feedback_count, @limit, page @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] @state = false diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 426d1b56..2c4f1088 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -27,8 +27,10 @@ class JournalsForMessage < ActiveRecord::Base :datetime => Proc.new {|o| o.updated_on }, :author => Proc.new {|o| o.user }, :description => Proc.new{|o| o.notes }, - :type => Proc.new {|o| o.jour_type }#, - #:url => Proc.new {|o| ''}#{:controller => 'documents', :action => 'show', :id => o.id}} + :type => Proc.new {|o| o.jour_type }, + :url => Proc.new {|o| + (o.jour.kind_of? Project) ? {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} : {} + }#{:controller => 'documents', :action => 'show', :id => o.id}} acts_as_activity_provider :author_key => :user_id, :timestamp => "#{self.table_name}.updated_on", :find_options => {:include => :project }