How to disable ActiveModel::Serializers for a specific controller?

active-model-serializers, rails-api, ruby, ruby-on-rails

Solution

You can also do:

respond_with @your_object, serializer: nil

Problem

We're using active_model_serializers - 0.8.1 in a Rails application. The app has some API specific controllers inheriting from ActionController::Metal in a way similar to rails-api's ActionController::API. Well we want to use ActiveModel::Serializers only for the API controllers mentioned above. Is that possible, how? Note: As mentioned in the documentation use of a serializer can explicitly be avoided by replacing `render :json` with: `render :json => @your_object.to_json` We are seeking a more elegant solution than the one above. Thanks.

Original source