From f1e2a425ff837deffe29f3717ff58439b519d53b Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 5 May 2015 12:32:25 +0200 Subject: [PATCH] Corrected with rubocop cop 'Lint/Loop'. --- .rubocop.yml | 2 -- app/models/token.rb | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 92c0ca43f..438bcb4ad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -277,5 +277,3 @@ Style/ModuleFunction: Enabled: false Style/AccessModifierIndentation: Enabled: false -Lint/Loop: - Enabled: false diff --git a/app/models/token.rb b/app/models/token.rb index 518dc66d3..084df589c 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -28,8 +28,11 @@ class Token < ActiveRecord::Base private def generate_token - begin + + loop do self.name = SecureRandom.hex(20) - end while Token.exists?( name: self.name ) + + break if !Token.exists?( name: self.name ) + end end end