Skip to content

Commit

Permalink
add labels params to episodes_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfiredrill committed Oct 28, 2023
1 parent fd6d33a commit 00e5a5b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/api/my_shows/episodes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def update
@scheduled_show.attributes = create_params.except(:image_filename).except(:image)
end

if labels_params.has_key? :label_ids
@scheduled_show.labels = Label.find(labels_params[:label_ids])
end

if @scheduled_show.save
ActiveSupport::Notifications.instrument 'scheduled_show.updated', current_user: current_user.email, radio: @current_radio.name, show: @scheduled_show.title, params: create_params
render json: @scheduled_show
Expand All @@ -19,6 +23,12 @@ def update
end

private
def labels_params
ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [
:labels
])
end

def create_params
ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [
:title, :radio_id, :start_at,
Expand Down

0 comments on commit 00e5a5b

Please sign in to comment.