Don't error on posts#latest if a post does not have a topic

This commit is contained in:
James Kiesel
2015-10-16 14:44:48 +03:00
parent ccdd614d7f
commit 695b366a03
3 changed files with 28 additions and 2 deletions

View File

@ -42,7 +42,7 @@ class PostsController < ApplicationController
.limit(50)
# Remove posts the user doesn't have permission to see
# This isn't leaking any information we weren't already through the post ID numbers
posts = posts.reject { |post| !guardian.can_see?(post) }
posts = posts.reject { |post| !guardian.can_see?(post) || post.topic.blank? }
counts = PostAction.counts_for(posts, current_user)
respond_to do |format|