Sha256: 57fe6349baff362d6cf634199612382f023210769690308d958a7c18ec41bb6c
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
class Article include Mongoid::Document include Mongoid::Timestamps 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 field :status, type: Symbol field :deletion_date, type: DateTime, default: nil embeds_many :comments, cascade_callbacks: true, inverse_of: :article embeds_one :permalink, inverse_of: :linkable belongs_to :author, class_name: 'User', inverse_of: :articles, index: true validates :title, presence: true validates_inclusion_of :status, in: [:pending], on: :create validates_inclusion_of :status, in: %i[approved rejected], on: :update validates_length_of :title, within: 8..16 validates_length_of :content, minimum: 200 validates_absence_of :deletion_date if Mongoid::Compatibility::Version.mongoid4_or_newer? index({ title: 1 }, unique: true, background: true, drop_dups: true) index(published: 1) index('permalink._id' => 1) accepts_nested_attributes_for :permalink end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid-rspec-4.1.0 | spec/models/article.rb |
mongoid-rspec-4.0.1 | spec/models/article.rb |