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

15
app/models/book.rb Normal file
View File

@@ -0,0 +1,15 @@
class Book < ApplicationRecord
include Accessable, Sluggable
has_many :leaves, dependent: :destroy
has_one_attached :cover, dependent: :purge_later
scope :ordered, -> { order(:title) }
scope :published, -> { where(published: true) }
enum :theme, %w[ black blue green magenta orange violet white ].index_by(&:itself), suffix: true, default: :blue
def press(leafable, leaf_params)
leaves.create! leaf_params.merge(leafable: leafable)
end
end