lib/mongoid/fields/localized.rb in mongoid-6.0.2 vs lib/mongoid/fields/localized.rb in mongoid-6.0.3

- old
+ new

@@ -75,12 +75,17 @@ # @return [ Object ] The object for the locale. # # @since 3.0.0 def lookup(object) locale = ::I18n.locale - if value = object[locale.to_s] - value - elsif fallbacks? && ::I18n.respond_to?(:fallbacks) + + value = if object.key?(locale.to_s) + object[locale.to_s] + elsif object.key?(locale) + object[locale] + end + return value unless value.nil? + if fallbacks? && ::I18n.respond_to?(:fallbacks) object[::I18n.fallbacks[locale].map(&:to_s).find{ |loc| object.has_key?(loc) }] end end end end