From 38d1c7f3c60df93b8e8dc61a1dd28fd0657bc0f0 Mon Sep 17 00:00:00 2001 From: Fabian Oudhaarlem Date: Mon, 10 Aug 2020 10:35:09 +0200 Subject: [PATCH] Use try instead of safe navigation operator on possible undefined attribute Since the safe navigation operator does raise on undefined methods we should use try instead. --- app/models/spree/user_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index bfcd15e..5965e35 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -5,7 +5,7 @@ def self.prepended(base) end def ensure_mollie_customer - return if mollie_customer_id&.present? + return if try(:mollie_customer_id).present? # Don't create Mollie customers if spree_auth_devise is not installed. return unless defined? Spree::User