- Book-styled UI with parchment aesthetic and Russian navigation - Characters model with Konva.js 2D canvas drawing (draggable shapes) - StoryPages model with character association and page navigation - Stimulus controllers: canvas (editor) + canvas-preview (read-only) - Full Russian interface: all labels, buttons, flash messages in Russian
19 lines
462 B
Ruby
19 lines
462 B
Ruby
# frozen_string_literal: true
|
|
|
|
class StoryPage < ApplicationRecord
|
|
belongs_to :character, optional: true
|
|
|
|
validates :content, length: { maximum: 5000 }
|
|
validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
|
|
|
default_scope { order(:position, :created_at) }
|
|
|
|
before_create :assign_position
|
|
|
|
private
|
|
|
|
def assign_position
|
|
self.position = (StoryPage.unscoped.maximum(:position) || -1) + 1 if position.zero?
|
|
end
|
|
end
|