1
0
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:
Philipp Fischbeck 2015-02-12 18:26:02 +01:00
parent c124808ffe
commit b1d0daf47a

View File

@ -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