-
Type: Task
-
Resolution: Done
-
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"]