diff options
author | jomo <git@jomo.tv> | 2017-07-07 02:05:04 +0200 |
---|---|---|
committer | jomo <git@jomo.tv> | 2017-07-07 02:05:04 +0200 |
commit | 8c6eb8ac17de84ebd34bb26652889b4c93b7e75a (patch) | |
tree | fc71e748908497d606ead353268a239dae62ac8e | |
parent | 72a6dcc54ad64d1168fbab7bb3d9cd663cc3b012 (diff) |
more fixes for order of threadreplies
-rw-r--r-- | app/controllers/forums_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/threadreplies_controller.rb | 2 | ||||
-rw-r--r-- | app/views/forums/show.html.erb | 2 | ||||
-rw-r--r-- | app/views/forumthreads/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/threadreplies/edit.html.erb | 2 |
5 files changed, 5 insertions, 5 deletions
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 @@ <div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>"> <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %> <div class="item-info"> - <% if rpl = thread.replies.last %> + <% if rpl = thread.replies.order(:id).last %> <%= rpl.author.name %> <% position = thread.replies.count - 1 diff --git a/app/views/forumthreads/index.html.erb b/app/views/forumthreads/index.html.erb index 02e425b..0c44352 100644 --- a/app/views/forumthreads/index.html.erb +++ b/app/views/forumthreads/index.html.erb @@ -60,7 +60,7 @@ <div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>"> <%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %> <div class="item-info"> - <% if rpl = thread.replies.last %> + <% if rpl = thread.replies.order(:id).last %> <%= rpl.author.name %> <% position = thread.replies.count - 1 diff --git a/app/views/threadreplies/edit.html.erb b/app/views/threadreplies/edit.html.erb index c009cb0..8296d9c 100644 --- a/app/views/threadreplies/edit.html.erb +++ b/app/views/threadreplies/edit.html.erb @@ -1,7 +1,7 @@ <% title "Edit Thread Reply: #{@reply.thread.title}" %> <% - position = @reply.thread.replies.index(@reply) + position = @reply.thread.replies.order(:id).index(@reply) page = position / Kaminari.config.default_per_page + 1 %> |