Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added edit playlist endpoint #62

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/controllers/playlists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class PlaylistsController < ApplicationController
before_action :authenticate_user!
before_action :set_playlist_and_song, only: %i[add_song remove_song]
before_action :set_playlist, only: %i[destroy]
before_action :set_playlist, only: %i[destroy update]

# GET /playlists (Returns current users playlists, but not with songs)
def index
Expand Down Expand Up @@ -67,6 +67,15 @@ def add_song
end
end

# PATCH /playlists/:id
def update
if @playlist.update(playlist_params)
render json: @playlist, status: :ok
else
render json: { error: 'Failed to update playlist' }, status: :unprocessable_entity
end
end

# DELETE /playlists/#/remove_song/#
def remove_song
if @playlist.songs.delete(@song)
Expand Down
Loading