Avoid ternary operator usage when appending/creating I18n keys

When using the OR operator, if the left side of the expression evaluates
to false, its right side is taken into consideration. Since in Ruby nil
is false, we can avoid using conditionals for this particular scenario
This commit is contained in:
Angel Perez
2018-08-20 09:57:39 -04:00
committed by Javi Martín
parent 304c970d59
commit 1835bac7e4

View File

@@ -66,10 +66,9 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
locale = params[:locale] || I18n.locale
translations = I18n.backend.send(:translations)[locale.to_sym]
translations.each do |k, v|
@content[k.to_s] = I18nContent.flat_hash(v).keys.map { |s|
@existing_keys["#{k.to_s}.#{s}"].nil? ? I18nContent.new(key: "#{k.to_s}.#{s}") :
@existing_keys["#{k.to_s}.#{s}"]
translations.each do |key, value|
@content[key.to_s] = I18nContent.flat_hash(value).keys.map { |string|
@existing_keys["#{key.to_s}.#{string}"] || I18nContent.new(key: "#{key.to_s}.#{string}")
}
end
end