Use detect instead of select.first

This commit is contained in:
Javi Martín
2018-10-18 00:34:27 +02:00
committed by decabeza
parent b745ddc9dd
commit c8d3c8fc1b

View File

@@ -37,9 +37,7 @@ module TranslatableFormHelper
end
def existing_translation_for(locale)
# Use `select` because `where` uses the database and so ignores
# the `params` sent by the browser
@object.translations.select { |translation| translation.locale == locale }.first
@object.translations.detect { |translation| translation.locale == locale }
end
def new_translation_for(locale)