title: JSON request not parsed into parameters
body: <p>Having spent an afternoon googling and testing, I am convinced there is a piece of rails magic missing, but have no idea where it is.</p>
  
  <p>I have a test that replicates the error seen in production.</p>
  
  <p>Rails 4.2.11.13</p>
  
  <p>Using the protected_attributes gem (so not a strong parameters issue)</p>
  
  <p>I successfully send a json request to an api controller, but it only creates an empty version of the payment_allocation parameter.</p>
  
  <p>Controller...</p>
  
  <pre><code>class Api::V1::PaymentAllocationsController &lt; Api::ApiController
    def create
      p request.content_type
      p request.body.read
      p params
      p self._wrapper_options
    end
  end 
  </code></pre>
  
  <p>The body of the request as seen in the controller...</p>
  
  <pre><code>"{\"amount\":123.33,\"transaction_type\":\"Transaction\",\"claim_number\":\"ABC-123\",\"resolved\":false,\"paid_on\":\"2000-01-01\"}"
  </code></pre>
  
  <p>The content type....
    <strong>"application/json"</strong></p>
  
  <p>The resulting params object...</p>
  
  <pre><code>{"controller"=&gt;"api/v1/payment_allocations", "action"=&gt;"create", "payment_allocation"=&gt;{}}
  </code></pre>
  
  <p>And I confirmed that all the necessary attributes are available to the options used by wrap_parameters</p>
  
  <pre><code> &lt;struct ActionController::ParamsWrapper::Options name="payment_allocation", 
  format=[:json], 
  include=["paid_on", "amount", "resolved", "claim_number", "transaction_type"], 
  exclude=nil, klass=Api::V1::PaymentAllocationsController, 
  model=PaymentAllocation(id: integer, paid_on: date, claim_number: string, transaction_type: string, amount: decimal, resolved: boolean)&gt;
  </code></pre>
  
  <p>The wrap_parameters initializer is like so...</p>
  
  <pre><code># Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
  ActiveSupport.on_load(:action_controller) do
    wrap_parameters format: [:json]
  end
  
  # Disable root element in JSON by default.
  ActiveSupport.on_load(:active_record) do
    self.include_root_in_json = false
  end
  </code></pre>
  
  <p>And I have confirmed that the initializer is being called.</p>
  
  <p>So wrap_parameters has the right class, the right attributes, etc, but does not actually set  the parameter values in payment_allocation. </p>
  
  <p>My best is guess is that something can't parse the json string, but JSON.parse for the above string returns this...</p>
  
  <pre><code>{"amount"=&gt;123.33, "transaction_type"=&gt;"Transaction", "claim_number"=&gt;"ABC-123", "resolved"=&gt;false, "paid_on"=&gt;"2000-01-01"}
  </code></pre>
  
  <p>Happy for any hints.</p>
  
  <p>(BTW, I have an app with the same code in the same version of rails that does not have this issue.)</p>