From 31d5c188d8dfc39546318407d9cb59f11ea1220d Mon Sep 17 00:00:00 2001 From: Tony Miller Date: Mon, 20 Nov 2023 19:10:17 -0800 Subject: [PATCH] destroy episode api --- app/controllers/api/my_shows/episodes_controller.rb | 8 ++++++++ config/routes.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/my_shows/episodes_controller.rb b/app/controllers/api/my_shows/episodes_controller.rb index 97625b8f..256096ab 100644 --- a/app/controllers/api/my_shows/episodes_controller.rb +++ b/app/controllers/api/my_shows/episodes_controller.rb @@ -22,6 +22,14 @@ def update end end + def destroy + @scheduled_show = @current_radio.scheduled_shows.friendly.find(params[:id]) + authorize! :destroy, @scheduled_show + if @scheduled_show.destroy + render json: @scheduled_show + end + end + private def labels_params ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [ diff --git a/config/routes.rb b/config/routes.rb index f2db4e64..5aa7d7a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -121,7 +121,7 @@ # meant only for consumption by datafruits frontend app namespace :api do resources :my_shows, only: [:index, :create, :update, :destroy, :show] do - resources :episodes, only: [:update], controller: 'my_shows/episodes' + resources :episodes, only: [:update, :destroy], controller: 'my_shows/episodes' end resources :show_series, only: [:index, :show] do resources :episodes, only: [:index, :show], controller: 'show_series/episodes'