Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4275

localized field returns nil if fallbacks is empty array

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 5.1.2, 5.1.3
    • Fix Version/s: 6.0.0, 5.1.4
    • Component/s: None
    • Labels:
      None
    • Sprint:
      Ruby Sprint 35

      Description

      When setting the I18n.fallbacks for the current local to an empty array it return nil instead an existing value.

      Example

      class Example
        include Mongoid::Document
        field :name, type: String, localize: true
      end
      

      Test code:

      I18n.locale = :en
      doc = Example.new
      doc.name = "test"
      doc.name_translations
      # returns {"en"=>"test"}
      doc.name 
      # returns "name"
       
      I18n.fallbacks[:en] = []
      doc.name_translations
      # returns {"en"=>"test"}
      doc.name 
      # returns  nil     <<< BUG!
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: