From 83fee4199bb021cc6995896cba1c360d1cb5480c Mon Sep 17 00:00:00 2001 From: Mark Donnelly Date: Fri, 12 Dec 2014 10:35:16 -0500 Subject: [PATCH] Don't clobber the JSON MIME type. simple_datatables was preventing Rails from parsing POST messages with a JSON body. The reason was that Mime::Type.register will associate a symbol with a mime type for both content generation (outbound HTTP responses, for instance) and content parsing (inbound HTTP requests), so when the middleware retrieved the identifying symbol associated with the application/json datatype, it got back :datatables, which it ignored. Mime::Type.register_alias will associate the symbol with the mime type for content generation only, so parsing the JSON body into a parameters array still works. --- lib/simple_datatables.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/simple_datatables.rb b/lib/simple_datatables.rb index 7ca7bc7..f39b3ae 100644 --- a/lib/simple_datatables.rb +++ b/lib/simple_datatables.rb @@ -1,6 +1,6 @@ require 'rails' -Mime::Type.register "application/json", :datatables +Mime::Type.register_alias "application/json", :datatables module SimpleDatatables module Rails