Backported r11424 from trunk (#12243).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11594 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2013-03-11 18:27:46 +00:00
parent 4b010fb653
commit 878e85848f
2 changed files with 24 additions and 5 deletions
+9 -5
View File
@@ -39,14 +39,18 @@ class BoardsController < ApplicationController
sort_init 'updated_on', 'desc'
sort_update 'created_on' => "#{Message.table_name}.created_on",
'replies' => "#{Message.table_name}.replies_count",
'updated_on' => "#{Message.table_name}.updated_on"
'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
@topic_count = @board.topics.count
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all(
:include => [:author, {:last_reply => :author}],
:limit => @topic_pages.items_per_page,
:offset => @topic_pages.current.offset)
@topics = @board.topics.
reorder("#{Message.table_name}.sticky DESC").
includes(:last_reply).
limit(@topic_pages.items_per_page).
offset(@topic_pages.current.offset).
order(sort_clause).
preload(:author, {:last_reply => :author}).
all
@message = Message.new(:board => @board)
render :action => 'show', :layout => !request.xhr?
}