e_paper/app/models/paper.rb

32 lines
728 B
Ruby
Raw Permalink 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, type: DateTime
2017-07-05 09:16:55 +00:00
field :description, localize: true
field :mailed, type: Boolean, default: false
field :ready_to_send, type: Boolean, default: false
2017-08-07 07:46:44 +00:00
mount_uploader :image, ImageUploader
2017-07-05 09:16:55 +00:00
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