From 1f31435a7b7ff549fa8765923157d0c66682caba Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 4 Sep 2015 13:34:21 +1000 Subject: [PATCH] correct handling of data hash parsing --- app/models/notification.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index 842d65726..e142f57b2 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -77,8 +77,12 @@ class Notification < ActiveRecord::Base # Be wary of calling this frequently. O(n) JSON parsing can suck. def data_hash @data_hash ||= begin + return nil if data.blank? - JSON.parse(data).with_indifferent_access + parsed = JSON.parse(data) + return nil if parsed.blank? + + parsed.with_indifferent_access end end