Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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):
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