Sha256: f7680f0b6eecf2f3ad5af10ecc8fceee274266d686b35ff05e93e5584d26a3f2

Contents?: true

Size: 467 Bytes

Versions: 8

Compression:

Stored size: 467 Bytes

Contents

# frozen_string_literal: true

class Book
  include Mongoid::Document
  include Mongoid::Attributes::Dynamic
  include Mongoid::Timestamps
  field :title, type: String
  field :chapters, type: Integer
  belongs_to :series
  belongs_to :person, autobuild: true
  has_one :rating, as: :ratable, dependent: :nullify

  after_initialize do |doc|
    doc.chapters = 5
  end

  embeds_many :pages, cascade_callbacks: true
  embeds_many :covers, cascade_callbacks: true
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoid-8.1.7 spec/support/models/book.rb
mongoid-8.1.6 spec/support/models/book.rb
mongoid-8.1.5 spec/support/models/book.rb
mongoid-8.1.4 spec/support/models/book.rb
mongoid-8.1.3 spec/support/models/book.rb
mongoid-8.1.2 spec/support/models/book.rb
mongoid-8.1.1 spec/support/models/book.rb
mongoid-8.1.0 spec/support/models/book.rb