Skip to content

Commit

Permalink
Add a destroy action for aeroplane
Browse files Browse the repository at this point in the history
  • Loading branch information
rubydevi committed Nov 5, 2023
1 parent 25f70db commit 33cda59
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/api/v1/aeroplanes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ def update

# DELETE /aeroplanes/1
def destroy
@aeroplane.destroy!
@aeroplane = Aeroplane.find(params[:id])

if @aeroplane.destroy
render json: { message: 'Aeroplane deleted successfully' }, status: :no_content
else
render json: { error: 'Failed to delete aeroplane' }, status: :unprocessable_entity
end
end

private
Expand Down

0 comments on commit 33cda59

Please sign in to comment.