This commit is contained in:
15
app/models/leaf.rb
Normal file
15
app/models/leaf.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class Leaf < ApplicationRecord
|
||||
include Editable, Positionable
|
||||
|
||||
belongs_to :book, touch: true
|
||||
delegated_type :leafable, types: Leafable::TYPES, dependent: :destroy
|
||||
positioned_within :book, association: :leaves, filter: :active
|
||||
|
||||
enum :status, %w[ active trashed ].index_by(&:itself), default: :active
|
||||
|
||||
scope :with_leafables, -> { includes(:leafable) }
|
||||
|
||||
def slug
|
||||
title.parameterize.presence || "-"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user