e_paper/app/models/paper.rb

31 lines
689 B
Ruby
Raw Normal View History

2017-07-05 09:16:55 +00:00
class Paper
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitTag::Taggable
include OrbitCategory::Categorizable
include Slug
field :title,as: :slug_title, localize: true
field :period, localize: true
field :description, localize: true
field :mailed, type: Boolean, default: false
field :ready_to_send, type: Boolean, default: false
has_many :topics, :dependent => :destroy
scope :can_display, ->{where(:is_hidden=>false,:title.ne => "").order_by([:is_top, :desc])}
def self.find_by_param(input)
self.find_by(uid: input)
end
def send_epaper
self.ready_to_send = true
self.save
end
end