Skip to content

Commit

Permalink
LTI-411: use exists? instead of where for performance (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariam05 authored Dec 6, 2024
1 parent f1719e5 commit 66c3a60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def generate_unique_code
def shared_code_presence
errors.add(:shared_code, "The shared code can't be blank when 'Use Shared Code' is enabled") && return if shared_code.blank?

return if Room.where(code: shared_code, tenant: tenant).exists?
return if Room.exists?(code: shared_code, tenant: tenant)

errors.add(:shared_code, 'A room with this code could not be found')
end

0 comments on commit 66c3a60

Please sign in to comment.