Sha256: 9090c20abc6cbeef77ba13b402212b9bee7cda2d8afed53e889346d3fe0fae14

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

module Bongo
  class Article
    include Mongoid::Document
    include Mongoid::Timestamps::Updated
    include Mongoid::Slug

    slug :title, history: true

    field :title, type: String
    field :text, type: String
    field :publish_at, type: Date

    scope :published, -> { where(:publish_at.lte => Date.today) }

    # Mongoid (v7.0.8) doesn't have a cache_version method on its document.
    # This causes https://jira.mongodb.org/browse/MONGOID-4680 when trying to
    # use Rails collection caching.
    def cache_version
      if respond_to?(:updated_at)
        updated_at.utc.to_s(:usec)
      else
        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bongo-0.2.0 app/models/bongo/article.rb