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

Sorting by localized fields in embedded docs doesn't work (again)

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

      Refers to: MONGOID-1745

      mongoid 3.0.14

      class Story
        include Mongoid::Document
        belongs_to :user
      
        field :name, localize: true
      
        scope :sorted, asc(:name)
      end
      
      class EmbeddedStory
        include Mongoid::Document
        embedded_in :user
      
        field :name, localize: true
      
        scope :sorted, asc(:name)
      end
      
      class User
        include Mongoid::Document
        has_many :stories
        embeds_many :embedded_stories
      
        field :name
      end
      
      user = User.create name: "John"
      
      %w(Beta Delta Alpha Charlie).each do |name|
        user.stories.create name: name
        user.embedded_stories.create name: name
      end
      
      1.9.3-p286 :034 >   user.stories.sorted.map(&:name)
       => ["Alpha", "Beta", "Charlie", "Delta"] 
      1.9.3-p286 :035 > user.embedded_stories.sorted.map(&:name)
       => ["Beta", "Delta", "Alpha", "Charlie"] 
      

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

              Created:
              Updated:
              Resolved: