Using ember and ember-data with it's built in JSON API support means my client is sending POST/PUT/PATCH requests with ContentType set to 'application/vnd.api+json'.
By default, even though I've set my adapter in my rails app to:json_api, the controller action for create/update doesn't receive any data.
After some troubleshooting and googling, I've found out I need to create an initializer to set the rails application to interpret 'application/vnd.api+json' as json:
ActionDispatch::ParamsParser::DEFAULT_PARSERS[Mime::Type.lookup('application/vnd.api+json')]=lambda do |body|
JSON.parse(body)
end
Once this was added, I'm receiving the data as expected.
The issue here is, i'm not sure if this is what I'm supposed to be doing.
- Will AMS at some point do this, or something similar internally?
- Should I do it this way?
- Should I do it some other, more proper way?
- Did I miss something altogether? Is it well documented already and I actually just didn't set some property somewhere?
If it's one of the first 3, I'm thinking it should be documented in some way.