This commit is contained in:
2025-11-07 13:34:32 -08:00
commit 1e8c5a972b
436 changed files with 11000 additions and 0 deletions

22
app/models/leafable.rb Normal file
View File

@@ -0,0 +1,22 @@
module Leafable
extend ActiveSupport::Concern
TYPES = %w[ Page Section Picture ]
included do
has_one :leaf, as: :leafable, inverse_of: :leafable, touch: true
has_one :book, through: :leaf
delegate :title, to: :leaf
end
class_methods do
def leafable_name
@leafable_name ||= ActiveModel::Name.new(self).singular.inquiry
end
end
def leafable_name
self.class.leafable_name
end
end