posts/random: fix pundit exception when no post is found.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user