Minor refactor (#1443)

* Rescue `ActiveRecord::RecordNotFound` exception instead of `StandardError`

* Replace `!blank?` call with `present?`
This commit is contained in:
Arun Kumar 2019-01-02 10:42:42 -05:00 committed by Ben Halpern
parent 0f8c08629b
commit cfcc204a20

View file

@ -17,10 +17,10 @@ class UserRoleService
def update_tag_moderators(user_ids, tag)
users = user_ids.map do |id|
User.find(id)
rescue StandardError
rescue ActiveRecord::RecordNotFound
tag.errors[:moderator_ids] << ": user id #{id} was not found"
end
return false if !tag.errors[:moderator_ids].blank?
return false if tag.errors[:moderator_ids].present?
# Don't have to worry about comparing old and new values.
tag.tag_moderator_ids.each do |id|
User.find(id).remove_role(:tag_moderator, tag)