russian-book-story/app/controllers/characters_controller.rb
viktorvsk f3d33199f0
Some checks failed
CI / Lint & Test (push) Has been cancelled
Deploy Status Page / Build & Deploy (push) Has been cancelled
Волшебная Книга: Russian book storytelling app
- 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
2026-04-25 15:29:15 +00:00

52 lines
1.0 KiB
Ruby

# frozen_string_literal: true
class CharactersController < ApplicationController
before_action :set_character, only: [:show, :edit, :update, :destroy]
def index
@characters = Character.all.order(:created_at)
end
def show
end
def new
@character = Character.new
end
def create
@character = Character.new(character_params)
if @character.save
redirect_to @character, notice: "Персонаж создан."
else
render :new, status: :unprocessable_entity
end
end
def edit
end
def update
if @character.update(character_params)
redirect_to @character, notice: "Персонаж обновлён."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@character.destroy
redirect_to characters_path, notice: "Персонаж удалён."
end
private
def set_character
@character = Character.find(params[:id])
end
def character_params
params.require(:character).permit(:name, :description, :canvas_data, :color)
end
end