29 lines
697 B
Ruby
29 lines
697 B
Ruby
# encoding: utf-8
|
|
|
|
class PageContext
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include OrbitModel::Impression
|
|
include AutoConvertUnitHelper
|
|
|
|
field :update_user_id
|
|
field :version, :type => Integer , :default => 0
|
|
field :view_count, :type => Integer, :default => 0
|
|
field :content, localize: true
|
|
field :archived, :type => Boolean, :default => false
|
|
# field :current, :type => Boolean, :default => false
|
|
|
|
belongs_to :page
|
|
before_create do |record|
|
|
last_version = record.page.page_contexts.order(:version=>-1).first.version rescue 0
|
|
record.version = last_version + 1
|
|
end
|
|
def pp_object
|
|
page.title
|
|
end
|
|
|
|
def title
|
|
self.page.title
|
|
end
|
|
|
|
end |