Changing Active Model Serializers Default Adapter

心已入冬 提交于 2019-11-30 08:38:16

In general, initilizers are put under the app/config/initializers directory in a Rails app.

So, in your case, you can create a new file there: ams.rb and put those content in that file:

# app/config/initializers/ams.rb    
ActiveModel::Serializer.config.adapter = :json_api

Also, see this github issue.

If you want to be using the :json_api format, you have to use the 0.10.0 branch off of Github.

For newer version of AMS put this to config/initializers/ams.rb:

require 'active_model_serializers'

ActiveModelSerializers.config.adapter = :json_api

Create a new file with any name inside app/config/initializers/ and add:

ActiveModelSerializers.config.adapter = :json_api

All the files under initalizers directory run during initialization irrespective of the file name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!