From ef3f390bba899d05ea52d522ae55f66853f4d7a0 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 1 Jan 2017 04:04:46 -0600 Subject: [PATCH] Fix #2813: /posts/random.json does not redirect nicely. --- app/controllers/posts_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index b50ad8716..96bc614d3 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -102,7 +102,9 @@ class PostsController < ApplicationController count = Post.fast_count(params[:tags], :statement_timeout => CurrentUser.user.statement_timeout) @post = Post.tag_match(params[:tags]).reorder("").offset(rand(count)).first raise ActiveRecord::RecordNotFound if @post.nil? - redirect_to post_path(@post, :tags => params[:tags]) + respond_with(@post) do |format| + format.html { redirect_to post_path(@post, :tags => params[:tags]) } + end end def mark_as_translated