forked from mirrors/catstodon
Fix Rails/WhereExists
cop in FeaturedTag model (#28791)
This commit is contained in:
parent
3d82040b26
commit
da31792ac7
2 changed files with 5 additions and 2 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue