mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Prevent N+1 on title validation
This commit is contained in:
parent
c124808ffe
commit
b1d0daf47a
@ -7,7 +7,7 @@ class Translation < ActiveRecord::Base
|
||||
self.per_page = 50
|
||||
|
||||
def title_is_unique_among_other_problems
|
||||
Problem.where.not(id: problem_id).each do |problem|
|
||||
Problem.includes(:translation).where.not(id: problem_id).each do |problem|
|
||||
if problem.is_translated? and problem.title == title
|
||||
errors.add(:title, :taken)
|
||||
break
|
||||
|
||||
Loading…
Reference in New Issue
Block a user