/
tofflin
/
music_project
Обзор
Документация
Войти
/
tofflin
/
music_project
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
app/controllers/strategy_controller.rb
25 строк
797 B
tofflin
добавлены артист и альбом
19 июн 2025, 22:18
19 июн 2025, 22:18
87c6783
Код
Авторство
О чём код?
class StrategyController < ApplicationController before_action :authenticate_user! def update new_user_type = params[:user_type] unless User.user_types.key?(new_user_type) render json: { error: "Invalid subscription type. Allowed: #{User.user_types.keys.join(', ')}" }, status: :unprocessable_entity return end if current_user.update(user_type: new_user_type) render json: { message: "Subscription updated to #{new_user_type}", user_type: current_user.user_type, can_create_artist: current_user.can_create_artist?, can_create_album: current_user.can_create_album? } else render json: { errors: current_user.errors.full_messages }, status: :unprocessable_entity end end end