Avoid exception when object.user is nil

This commit is contained in:
Stephen Chung 2017-12-07 15:08:44 +08:00 committed by GitHub
parent 07cb0005b0
commit 0607abe2fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -49,8 +49,8 @@ after_initialize do
def excerpt
Post.excerpt(object.cooked, 70)
end
def username; object.user.username; end
def avatar_template; object.user.avatar_template; end
def username; object.user && object.user.username; end
def avatar_template; object.user && object.user.avatar_template; end
end
# Run a data explorer query on the currently connected database.