posts/random: fix pundit exception when no post is found.

This commit is contained in:
evazion
2020-03-31 19:12:57 -05:00
parent 08ce5a71c4
commit 25776a062c
2 changed files with 7 additions and 1 deletions

View File

@@ -80,8 +80,9 @@ class PostsController < ApplicationController
end
def random
@post = authorize Post.tag_match(params[:tags]).random
@post = Post.tag_match(params[:tags]).random
raise ActiveRecord::RecordNotFound if @post.nil?
authorize @post
respond_with(@post) do |format|
format.html { redirect_to post_path(@post, :tags => params[:tags]) }
end