diff --git a/app/controllers/creatures_controller.rb b/app/controllers/creatures_controller.rb index 11bc911..ad02c6b 100644 --- a/app/controllers/creatures_controller.rb +++ b/app/controllers/creatures_controller.rb @@ -28,6 +28,12 @@ class CreaturesController < ApplicationController render json: {}, status: 404 end + def destroy + @creature = Creature.find(params[:id]) + @creature.destroy! + head :no_content + end + private def create_or_update_params params.require(:creature).permit(:name) diff --git a/config/routes.rb b/config/routes.rb index 7162598..aa692af 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,7 @@ Rails.application.routes.draw do get '/creatures/:id', to: 'creatures#show' post '/creatures', to: 'creatures#create' put '/creatures/:id', to: 'creatures#update' + delete '/creatures/:id', to: 'creatures#destroy' # Defines the root path route ("/") root 'home#welcome'