publication/app/models/chapter.rb

29 lines
735 B
Ruby
Raw Normal View History

2018-10-04 02:47:23 +00:00
class Chapter
include Mongoid::Document
include Slug
2023-06-23 10:25:35 +00:00
include OrbitTag::Taggable
2018-10-04 02:47:23 +00:00
2023-07-21 02:10:22 +00:00
field :title, as: :slug_title, type: String, localize: true
2018-10-04 02:47:23 +00:00
field :author, type: String, localize: true
field :author_description, type: String, localize: true
2023-06-23 10:25:35 +00:00
field :author_url, type: String
2018-10-04 02:47:23 +00:00
field :text, localize: true
field :page, type: String
field :sort_number, type: Integer
2023-06-23 10:25:35 +00:00
field :is_online_flipping_reader, :type => Boolean, :default => false
field :keywords, type: String, localize: true
2018-10-04 02:47:23 +00:00
2023-06-04 14:41:53 +00:00
belongs_to :publication
2023-06-23 10:25:35 +00:00
has_many :chapter_files, :dependent => :destroy, :class_name => "ChapterFile"
accepts_nested_attributes_for :chapter_files, :allow_destroy => true
def chapter_file
chapter_files[0]
end
2018-10-04 02:47:23 +00:00
end