From 92cfdb9467901e7c7f46d71a5984daacdbbdb7c8 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 13 May 2015 18:30:51 +0100 Subject: [PATCH] install robust_params_parser to get rid of 500 status code when receiving requests that send the header content-type: application/json but no valid json in body --- Gemfile | 1 + config/application.rb | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 107a12ab..b53aacd1 100644 --- a/Gemfile +++ b/Gemfile @@ -124,6 +124,7 @@ source 'https://rubygems.org' do gem 'compass-rails' gem 'strong_parameters' gem 'postgres_ext' + gem 'robust_params_parser' # ElasticSearch client gem 'tire' # /DROP BEFORE RAILS 4 diff --git a/config/application.rb b/config/application.rb index 83e85658..eedb1e9d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -40,6 +40,9 @@ class Application < Rails::Application config.rakismet.url = ENV['AKISMET_URL'] config.exceptions_app = self.routes + + # DROP BEFORE RAILS 4 + config.middleware.swap ActionDispatch::ParamsParser, ::RobustParamsParser, {} end end