Sha256: 947fc56ddda1f4d3ac8a819c0fa5b4f8e435a69a144223b053d1e81659627f0d

Contents?: true

Size: 825 Bytes

Versions: 4

Compression:

Stored size: 825 Bytes

Contents

class Article
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Paranoia
  include Mongoid::Versioning
  include Mongoid::MultiParameterAttributes

  field :title, :localize => true
  field :content
  field :published, :type => Boolean, :default => false
  field :allow_comments, :type => Boolean, :default => true
  field :number_of_comments, :type => Integer

  embeds_many :comments
  embeds_one :permalink
  belongs_to :author, :class_name => 'User', :inverse_of => :articles, :index => true

  validates :title, :presence => true

  validates_length_of :title, :within => 8..16
  validates_length_of :content, :minimum => 200

  index({ title: 1 }, { unique: true, background: true })
  index({ published: 1 })
  index({ 'permalink._id' => 1 })

  accepts_nested_attributes_for :permalink
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-rspec-1.8.1 spec/models/article.rb
mongoid-rspec-1.8.0 spec/models/article.rb
mongoid-rspec-1.7.0 spec/models/article.rb
mongoid-rspec-1.6.0 spec/models/article.rb