@ -12,4 +12,8 @@ class PeopleController < ApplicationController
def create
render json: Person.create(params["person"])
end
def delete
render json: Person.delete(params["id"])
@ -22,4 +22,9 @@ class Person
results = DB.exec("INSERT INTO people (name, age) VALUES ( '#{opts["name"]}', #{opts["age"]} );")
return { created:true }
def self.delete(id)
results = DB.exec("DELETE FROM people WHERE id=#{id};")
return { deleted: true }
@ -3,4 +3,5 @@ Rails.application.routes.draw do
get '/people', to: 'people#index'
get '/people/:id', to: 'people#show'
post '/people', to: 'people#create'
delete '/people/:id', to: 'people#delete'