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

Localized Field and clone

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.20
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      There is a problem with cloning model with localized fields:

      class ModelB < SubclassWithMongoid
      field :title, localize: true
      end

      m = Model.new(title: "Hello")
      m.title => "Hello"

      mc = m.clone
      mc.title => "

      { "en" => "hello" }"

      I think is because of:
      https://github.com/mongoid/mongoid/blob/master/lib/mongoid/copyable.rb#L21

      First document is transformed to hash like:
      {"_id"=>"510ba9e6a46d822ace000002", title => { "en" => "hello" }

      , _type => "ModelB" }

      It should be this:
      {"_id"=>"510ba9e6a46d822ace000002", title_translations =>

      { "en" => "hello" }

      , _type => "ModelB" }

            Assignee:
            durran Durran Jordan
            Reporter:
            macbury macbury
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: