Skip to content

Commit d08b975

Browse files
committed
[WIP #421] Exclude comments where the user is non-existant
1 parent 70eee3a commit d08b975

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

app/controllers/protips_controller.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ProtipsController < ApplicationController
22

33
before_action :access_required, only: [:new, :create, :edit, :update, :destroy, :me]
44
before_action :require_skills_first, only: [:new, :create]
5-
before_action :lookup_protip, only: [:show, :edit, :update, :destroy, :upvote, :tag, :flag, :queue, :feature, :delete_tag]
5+
before_action :lookup_protip, only: %i(show edit update destroy upvote tag flag queue feature delete_tag)
66
before_action :reformat_tags, only: [:create, :update]
77
before_action :verify_ownership, only: [:edit, :update, :destroy]
88
before_action :ensure_single_tag, only: [:subscribe, :unsubscribe]
@@ -404,8 +404,9 @@ def expand_query(query_string)
404404
end
405405
406406
def lookup_protip
407-
@protip = if public_id = params[:id]
408-
Protip.find_by_public_id(public_id.downcase)
407+
@protip = if params[:id].present?
408+
public_id = params[:id].to_s.strip.downcase
409+
Protip.find_by_public_id(public_id)
409410
else
410411
nil
411412
end

app/views/protips/_protip.html.haml

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@
111111
%h2.comments-header
112112
%i.fa.fa-comments
113113
Comments
114-
%ul.comment-list
115-
= render protip.comments
116-
114+
-# HACK: Ignore protip comments where the owner is non-existant
115+
-# TODO: Clean out old comments where the is no User associated
116+
%ul.comment-list= render protip.comments.select { |comment| comment.user }
117117
= render 'comments/add_comment'
118118

119119
- if defined?(:job) && !job.nil?

0 commit comments

Comments
 (0)