mirror of
https://github.com/mastodon/mastodon
synced 2024-11-27 06:18:17 +09:00
Fix Rails/WhereExists
cop in FeaturedTag model (#28791)
This commit is contained in:
parent
3d82040b26
commit
da31792ac7
@ -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 New Issue
Block a user