Merge pull request #3857 from gdpelican/fix-for-untopiced-posts

Don't error on posts#latest if a post does not have a topic
This commit is contained in:
Régis Hanol
2015-10-16 14:59:36 +02:00
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|