Created
December 13, 2017 17:01
-
-
Save ornerymoose/cfc9237680eeef13356ff57529162995 to your computer and use it in GitHub Desktop.
Attempting to run curl http://localhost:3000/api/v1/tickets.json -d {"heat_ticket_number": "123whatever", "customers_affected ": "34"} returns the following in server log: TypeError (compared with non class/module):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module API | |
module V1 | |
class Tickets < Grape::API | |
include API::V1::Defaults | |
resource :tickets do | |
desc "Return all tickets" | |
get "", root: :tickets do | |
Ticket.all | |
end | |
desc "Return a ticket" | |
params do | |
requires :id, type: String, desc: "ID of the ticket" | |
end | |
get ":id", root: "ticket" do | |
Ticket.where(id: permitted_params[:id]).first! | |
end | |
desc "Create a ticket" | |
params do | |
requires :heat_ticket_number, type: String | |
requires :customers_affected, type: String | |
end | |
#creates a new ticket | |
post do | |
Ticket.create!({ | |
heat_ticket_number:params[:heat_ticket_number], | |
customers_affected:params[:customers_affected] | |
}) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment