From 60e1d1379db7145c846aa29cc76187b55a36f347 Mon Sep 17 00:00:00 2001 From: Toks Date: Wed, 26 Nov 2014 13:27:28 -0500 Subject: [PATCH] Fix ?page=1 param appearing after creating/editing forum post It creates an extra unnecessary entry in back button history to go through. --- app/controllers/forum_posts_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index 21bb0037a..32ed122ed 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -42,14 +42,16 @@ class ForumPostsController < ApplicationController def create @forum_post = ForumPost.create(params[:forum_post]) - respond_with(@forum_post, :location => forum_topic_path(@forum_post.topic, :page => @forum_post.topic.last_page)) + page = @forum_post.topic.last_page if @forum_post.topic.last_page > 1 + respond_with(@forum_post, :location => forum_topic_path(@forum_post.topic, :page => page)) end def update @forum_post = ForumPost.find(params[:id]) check_privilege(@forum_post) @forum_post.update_attributes(params[:forum_post]) - respond_with(@forum_post, :location => forum_topic_path(@forum_post.topic, :page => @forum_post.forum_topic_page, :anchor => "forum_post_#{@forum_post.id}")) + page = @forum_post.forum_topic_page if @forum_post.forum_topic_page > 1 + respond_with(@forum_post, :location => forum_topic_path(@forum_post.topic, :page => page, :anchor => "forum_post_#{@forum_post.id}")) end def destroy