more fixes for order of threadreplies

This commit is contained in:
jomo
2017-07-07 02:05:04 +02:00
parent 72a6dcc54a
commit 8c6eb8ac17
5 changed files with 5 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ class ForumsController < ApplicationController
@threads = @forum.forumthreads.select {|f| f.can_read?(current_user) }.to_a
@threads.sort_by! do |t|
# sticky goes first, then sort by last activity (new replies)
[t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i]
[t.sticky ? 0 : 1, -(t.replies.order(:id).last.try(:created_at) || t.created_at).to_i]
end
@threads = Kaminari.paginate_array(@threads).page(params[:page])
end