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

references_many :default_order not respected

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

      class Comment
      include Mongoid::Document

      field :content

      referenced_in :post
      end

      class Post
      include Mongoid::Document

      field :title

      references_many :comments, :default_order => :_id.desc
      end

      <pre>
      post = Post.create :title => 'new post'
      post.comments.create :content => 'c1'
      post.comments.create :content => 'c2'
      </pre>

      For 2.0.0.beta.19 the following code work as expected:

      > post.comments.map(&:content) => ["c2", "c1"]

      But for 2.0.0.rc.6 the :default_order is ignored:

      > post.comments.map(&:content) => ["c1", "c2"]

            Assignee:
            Unassigned Unassigned
            Reporter:
            stonegao Stone, Gao
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: