diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 761a86b..206f01f 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -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 diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 946155d..a801fbc 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -37,7 +37,7 @@ class ThreadrepliesController < ApplicationController if @reply.update_attributes(reply_params) @reply.send_new_reply_mail(old_content) flash[:notice] = "Reply updated!" - position = @reply.thread.replies.index(@reply) + position = @reply.thread.replies.order(:id).index(@reply) page = position / Kaminari.config.default_per_page + 1 redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}" else diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index b232292..cfe3918 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -38,7 +38,7 @@