From db3aea185b5d21a14e61ca3c1939083103cc4fb6 Mon Sep 17 00:00:00 2001 From: MrYummy Date: Sun, 28 May 2017 17:42:39 -0400 Subject: Added Reply Reversal And Toggle --- app/controllers/forumthreads_controller.rb | 8 ++++++-- app/views/forumthreads/show.html.erb | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index b9b5714..b1dffd9 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -7,7 +7,11 @@ class ForumthreadsController < ApplicationController end def show - @replies = @thread.replies.page(params[:page]) + if params[:reverse] + @replies = @thread.replies.reverse_order.page(params[:page]) + else + @replies = @thread.replies.page(params[:page]) + end end def edit @@ -92,4 +96,4 @@ class ForumthreadsController < ApplicationController a += add params.require(:forumthread).permit(a) end -end \ No newline at end of file +end diff --git a/app/views/forumthreads/show.html.erb b/app/views/forumthreads/show.html.erb index 876d55d..82f8fb3 100644 --- a/app/views/forumthreads/show.html.erb +++ b/app/views/forumthreads/show.html.erb @@ -1,6 +1,12 @@ <%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %> -

<%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %>

- +

+ <%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %> + <% if params[:reverse] %> + <%= link_to "Reverse Replies", @thread, class: "btn right blue" %> + <% else %> + <%= link_to "Reverse Replies", forumthread_path(@thread, reverse: true), class: "btn right blue" %> + <% end %> +

<%= link_to(@thread.author.avatar(64), @thread.author, title: @thread.author.ign) %> @@ -44,4 +50,4 @@ <% else %>

Please <%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> to post a reply.

<% end %> -
\ No newline at end of file +
-- cgit v1.2.3