Skip to content

Instantly share code, notes, and snippets.

@ornerymoose
Created December 13, 2017 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ornerymoose/cfc9237680eeef13356ff57529162995 to your computer and use it in GitHub Desktop.
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):
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