Search code examples
ruby-on-railsrubyactive-model-serializers

Active Model Serializers: Configuration per serializer?


In the 0.10 branch of AMS, you can configure some options.

https://github.com/rails-api/active_model_serializers/blob/master/docs/general/configuration_options.md

Is it possible to configure those options on a per serializer basis? I'm migrating from a custom api to JSONAPI.


Solution

  • You could specified the adapter when you render json data in your controller:

    class UsersController < ApiController
      def index
        @users = User.all
        render json: @users, adapter: :json_api
      end
    end