Sha256: 566c73c7e716e204a91a66e5868a57eca2064a3bd34c6bf249783073e00bd18e
Contents?: true
Size: 1.04 KB
Versions: 32
Compression:
Stored size: 1.04 KB
Contents
module Endpoints class <%= plural_class_name %> < Base namespace "<%= url_path %>" do serializer Serializers::<%= singular_class_name %> get do encode serialize(<%= singular_class_name %>.all) end post do # warning: not safe <%= field_name %> = <%= singular_class_name %>.new(body_params) <%= field_name %>.save status 201 encode serialize(<%= field_name %>) end get "/:id" do |id| <%= field_name %> = <%= singular_class_name %>.first(id: id) || halt(404) encode serialize(<%= field_name %>) end patch "/:id" do |id| <%= field_name %> = <%= singular_class_name %>.first(id: id) || halt(404) # warning: not safe #<%= field_name %>.update(body_params) encode serialize(<%= field_name %>) end delete "/:id" do |id| <%= field_name %> = <%= singular_class_name %>.first(id: id) || halt(404) <%= field_name %>.destroy encode serialize(<%= field_name %>) end end end end
Version data entries
32 entries across 32 versions & 1 rubygems