Skip to content

Instantly share code, notes, and snippets.

@perplexes
Created January 22, 2010 16:38
Show Gist options
  • Save perplexes/283894 to your computer and use it in GitHub Desktop.
Save perplexes/283894 to your computer and use it in GitHub Desktop.
diff --git a/lib/sinatras-hat/actions.rb b/lib/sinatras-hat/actions.rb
index 9424a10..24f9c1b 100644
--- a/lib/sinatras-hat/actions.rb
+++ b/lib/sinatras-hat/actions.rb
@@ -21,6 +21,9 @@ module Sinatra
end
map.action :update, '/:id', :verb => :put do |request|
+ if request.env["rack.input"].size > 0
+ request.params.merge!(Hash.from_xml(request.env["rack.input"].read))
+ end
record = model.update(request.params) || request.not_found
result = record.save ? :success : :failure
responder.send(result, :update, request, record)
@@ -38,6 +41,9 @@ module Sinatra
end
map.action :create, '/', :verb => :post do |request|
+ if request.env["rack.input"].size > 0
+ request.params.merge!(Hash.from_xml(request.env["rack.input"].read))
+ end
record = model.new(request.params)
result = record.save ? :success : :failure
responder.send(result, :create, request, record)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment