diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 73ad0cac0..eaa86ad15 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -82,7 +82,6 @@ Rails/WhereExists: - 'app/lib/feed_manager.rb' - 'app/lib/status_cache_hydrator.rb' - 'app/lib/suspicious_sign_in_detector.rb' - - 'app/models/featured_tag.rb' - 'app/models/poll.rb' - 'app/models/session_activation.rb' - 'app/models/status.rb' diff --git a/app/models/featured_tag.rb b/app/models/featured_tag.rb index 7c36aa8b0..63cd67476 100644 --- a/app/models/featured_tag.rb +++ b/app/models/featured_tag.rb @@ -66,6 +66,10 @@ class FeaturedTag < ApplicationRecord end def validate_tag_uniqueness - errors.add(:name, :taken) if FeaturedTag.by_name(name).where(account_id: account_id).exists? + errors.add(:name, :taken) if tag_already_featured_for_account? + end + + def tag_already_featured_for_account? + FeaturedTag.by_name(name).exists?(account_id: account_id) end end