From 0607abe2fd7e27a8670986c2cc0eafe8c09d5cf0 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 7 Dec 2017 15:08:44 +0800 Subject: [PATCH] Avoid exception when object.user is nil --- plugin.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.rb b/plugin.rb index 342b5b9..62749d7 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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.