From 0b13c173f7a3a6d688b470d467b210331c0cd681 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Sep 2022 17:11:21 +0200 Subject: [PATCH] Fix ingredient boolean preview text If the translation is missing I18n returns a boolean instead of a string. Cast to string unless the value is nil. Closes #2329 --- app/models/alchemy/ingredients/boolean.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/alchemy/ingredients/boolean.rb b/app/models/alchemy/ingredients/boolean.rb index 8784982000..d09a02d7b0 100644 --- a/app/models/alchemy/ingredients/boolean.rb +++ b/app/models/alchemy/ingredients/boolean.rb @@ -14,7 +14,9 @@ def value # Used by the Element#preview_text method. # def preview_text(_max_length = nil) - Alchemy.t(value, scope: "ingredient_values.boolean") + return if value.nil? + + Alchemy.t(value.to_s, scope: "ingredient_values.boolean") end end end