留言url显示,以及留言分页的url处理

This commit is contained in:
yanxd 2014-03-22 09:24:59 +08:00
parent 34fd8a933a
commit 404568be89
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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 }