From 351ed12b2f0314f7dd6c31ef018d84ca2e48ad04 Mon Sep 17 00:00:00 2001 From: ysksn Date: Wed, 12 Dec 2018 13:54:09 +0900 Subject: [PATCH] Use find_or_initialize_by (#9504) --- app/services/pubsubhubbub/subscribe_service.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/services/pubsubhubbub/subscribe_service.rb b/app/services/pubsubhubbub/subscribe_service.rb index 2dba05b12f1..d2b85b85b2e 100644 --- a/app/services/pubsubhubbub/subscribe_service.rb +++ b/app/services/pubsubhubbub/subscribe_service.rb @@ -58,12 +58,7 @@ class Pubsubhubbub::SubscribeService < BaseService end def locate_subscription - subscription = Subscription.find_by(account: account, callback_url: callback) - - if subscription.nil? - subscription = Subscription.new(account: account, callback_url: callback) - end - + subscription = Subscription.find_or_initialize_by(account: account, callback_url: callback) subscription.domain = domain subscription.save! subscription