/
tofflin
/
music_project
Обзор
Документация
Войти
/
tofflin
/
music_project
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
app/controllers/artists_controller.rb
30 строк
805 B
tofflin
добавлены артист и альбом
19 июн 2025, 22:18
19 июн 2025, 22:18
87c6783
Код
Авторство
О чём код?
class ArtistsController < ApplicationController include ArtistSerialization before_action :authenticate_user! def create unless current_user.can_create_artist? render json: { error: "You must have an artist subscription" }, status: :forbidden return end if current_user.artist.present? render json: { error: "Artist profile already exists" }, status: :conflict return end @artist = current_user.build_artist(artist_params) if @artist.save render json: serialize_artist(@artist), status: :created else render json: { errors: @artist.errors.to_hash(full_messages: true) }, status: :unprocessable_entity end end private def artist_params params.require(:artist).permit(:artist_name, :bio, :genre, :cover_art) end end