问题
I am trying to save a message model in Emberjs. I am using the JSONAPIAdapter and JSONAPISerilzier.
My post to rails hits the right controller and action as a post, but if I look inside with Pry, the data attributes are not there. My payload:
{"data":{"attributes":{"body":"Why","user_id":"17"},"relationships":{"user":{"data":null},"conversation":{"data":null}},"type":"messages"}}
Content-Type:application/vnd.api+json
Rails params in the Rails console:
{"format"=>"json", "controller"=>"api/v1/messages", "action"=>"create"}
回答1:
So this may help someone else out.
You need to add support for the mime type for JSONAPI.
Add this to config/initializers/mime_types.rb
Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest application/vnd.api+json )
来源:https://stackoverflow.com/questions/32006492/post-to-rails-from-emberjs-using-jsonapi-adapter-rails-not-seeing-the-params