Update comment.rb

allow Comment#for_creator to handle null user id case
This commit is contained in:
Albert Yi
2016-12-27 11:32:41 -08:00
committed by GitHub
parent 390524c7f5
commit 0293d1d01c

View File

@@ -54,11 +54,11 @@ class Comment < ActiveRecord::Base
end
def for_creator(user_id)
where("creator_id = ?", user_id)
user_id.present? ? where("creator_id = ?", user_id) : where("false")
end
def for_creator_name(user_name)
for_creator(User.name_to_id(user_name).id)
for_creator(User.name_to_id(user_name))
end
def search(params)