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

localized field returns nil if fallbacks is empty array

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0, 5.1.4
    • Affects Version/s: 5.1.2, 5.1.3
    • Component/s: None
    • None

      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!
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            martin_cp Martin Stemmle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: