Sha256: 56e3af0d0c7e6348b3b1195e51af21c2912f0cb61576c06d8796cbe866ca4bf4

Contents?: true

Size: 1 KB

Versions: 15

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

class EmmCongress
  include Mongoid::Document

  embeds_many :legislators, class_name: 'EmmLegislator'

  field :name, type: String
end

class EmmLegislator
  include Mongoid::Document

  embedded_in :congress, class_name: 'EmmCongress'

  field :a, type: Integer, default: 0
  field :b, type: Integer, default: 0
end

# Models with associations with :class_name as a :: prefixed string

class EmmCcCongress
  include Mongoid::Document

  embeds_many :legislators, class_name: '::EmmCcLegislator'

  field :name, type: String
end

class EmmCcLegislator
  include Mongoid::Document

  embedded_in :congress, class_name: '::EmmCcCongress'

  field :a, type: Integer, default: 0
  field :b, type: Integer, default: 0
end

class EmmManufactory
  include Mongoid::Document

  embeds_many :products, order: :id.desc, class_name: 'EmmProduct'
end


class EmmProduct
  include Mongoid::Document

  embedded_in :manufactory, class_name: 'EmmManufactory'

  field :name, type: String
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
mongoid-7.1.11 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.10 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.9 spec/mongoid/association/embedded/embeds_many_models.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.8 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.0.13 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.7 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.0.12 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.6 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.0.11 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.5 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.4 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.0.10 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.0.8 spec/mongoid/association/embedded/embeds_many_models.rb
mongoid-7.1.2 spec/mongoid/association/embedded/embeds_many_models.rb