diff --git a/app/controllers/threadreplies_controller.rb b/app/controllers/threadreplies_controller.rb index 7df8aef..298dd75 100644 --- a/app/controllers/threadreplies_controller.rb +++ b/app/controllers/threadreplies_controller.rb @@ -18,7 +18,9 @@ class ThreadrepliesController < ApplicationController if @reply.save @reply.send_new_reply_mail @reply.send_new_mention_mail - redirect_to forumthread_path(@reply.thread) + "#reply-#{@reply.id}", notice: 'Reply created!' + position = thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}", notice: 'Reply created!' else flash[:alert] = "Could not create reply." redirect_to Forumthread.find(params[:forumthread_id]) @@ -36,7 +38,9 @@ class ThreadrepliesController < ApplicationController if @reply.update_attributes(reply_params) @reply.send_new_mention_mail(old_content) flash[:notice] = "Reply updated!" - redirect_to forumthread_path(@reply.thread) + "#reply-#{@reply.id}" + position = @reply.thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}" else flash[:alert] = "There was a problem while updating your reply" render action: "edit" diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index a9e776e..f09ea20 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -20,7 +20,11 @@ <% if last_reply && last_reply.created_at > last_thread.created_at %> <% if last_reply.thread.can_read?(current_user) %> <%= last_reply.author.name %> - <%= link_to "replied", forumthread_path(last_reply.thread) + "#reply-#{last_reply.id}" %> + <% + position = last_reply.thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> + <%= link_to "replied", forumthread_path(last_reply.thread, page: page) + "#reply-#{last_reply.id}" %> <%= ago last_reply.created_at %>. <% else %> Hidden diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 2612102..0612dad 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -29,7 +29,11 @@
<% if rpl = thread.replies.last %> <%= rpl.author.name %> - <%= link_to "replied", forumthread_path(thread) + "#reply-#{rpl.id}" %> + <% + position = thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> + <%= link_to "replied", forumthread_path(thread, page: page) + "#reply-#{rpl.id}" %> <%= ago rpl.created_at %>. <% else %> No replies yet. diff --git a/app/views/redstoner_mailer/new_post_comment_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mail.html.erb index b3ab99a..c2c5bca 100644 --- a/app/views/redstoner_mailer/new_post_comment_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mail.html.erb @@ -8,7 +8,11 @@ <%= render_md(@comment.content).html_safe %> -

<%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

+ <% + position = @comment.blogpost.comments.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> +

<%= link_to "Click here", blogpost_url(@comment.blogpost, page: page) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

Your Redstoner team

diff --git a/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb b/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb index a65e4a3..f33b2fd 100644 --- a/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_post_comment_mention_mail.html.erb @@ -8,7 +8,11 @@ <%= render_md(@comment.content).html_safe %> -

<%= link_to "Click here", blogpost_url(@comment.blogpost) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

+ <% + position = @comment.blogpost.comments.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> +

<%= link_to "Click here", blogpost_url(@comment.blogpost, page: page) + "#comment-#{@comment.id}", style: "text-decoration: none; color: #4096EE;" %> to view the blog post.

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

Your Redstoner team

diff --git a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb index 978a439..99f14f6 100644 --- a/app/views/redstoner_mailer/new_thread_reply_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_reply_mail.html.erb @@ -9,7 +9,11 @@ <%= render_md(@reply.content).html_safe %> -

<%= link_to "Click here", forumthread_url(@reply.thread) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.

+ <% + position = @reply.thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> +

<%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

Your Redstoner team

diff --git a/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb b/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb index caf73de..b053b59 100644 --- a/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb +++ b/app/views/redstoner_mailer/new_thread_reply_mention_mail.html.erb @@ -9,7 +9,11 @@ <%= render_md(@reply.content).html_safe %> -

<%= link_to "Click here", forumthread_url(@reply.thread) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.

+ <% + position = @reply.thread.replies.count - 1 + page = position / Kaminari.config.default_per_page + 1 + %> +

<%= link_to "Click here", forumthread_url(@reply.thread, page: page) + "#reply-#{@reply.id}", style: "text-decoration: none; color: #4096EE;" %> to view the thread.

If you have any questions or problems, just ask one of our <%= link_to "Staff", users_url(role: "staff"), style: "text-decoration: none; color: #4096EE;" %> in-game or on the forums!

Your Redstoner team