Sha256: 02206d658948ac7b52b301ef8db7e8d9780a497cf7feec58e3f3aa7402abde48

Contents?: true

Size: 647 Bytes

Versions: 14

Compression:

Stored size: 647 Bytes

Contents

class Animal
  include Mongoid::Document

  field :_id, type: String, overwrite: true, default: ->{ name.try(:parameterize) }

  field :name
  field :height, type: Integer
  field :weight, type: Integer
  field :tags, type: Array

  embedded_in :person
  embedded_in :circus, class_name: 'Circus' # class_name is necessary because ActiveRecord think the singular of Circus
                                            # is Circu

  validates_format_of :name, without: /\$\$\$/

  accepts_nested_attributes_for :person

  def tag_list
    tags.join(", ")
  end

  def tag_list=(_tag_list)
    self.tags = _tag_list.split(",").map(&:strip)
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongoid-7.0.13 spec/app/models/animal.rb
mongoid-7.0.12 spec/app/models/animal.rb
mongoid-7.0.11 spec/app/models/animal.rb
mongoid-7.0.10 spec/app/models/animal.rb
mongoid-7.0.8 spec/app/models/animal.rb
mongoid-7.0.7 spec/app/models/animal.rb
mongoid-7.0.6 spec/app/models/animal.rb
mongoid-7.0.5 spec/app/models/animal.rb
mongoid-7.0.4 spec/app/models/animal.rb
mongoid-7.0.3 spec/app/models/animal.rb
mongoid-7.0.2 spec/app/models/animal.rb
mongoid-7.0.1 spec/app/models/animal.rb
mongoid-7.0.0 spec/app/models/animal.rb
mongoid-7.0.0.beta spec/app/models/animal.rb