Getting the active_model_serializer for model

68 views Asked by At

I am trying to send multiple different objects over a generic request - more specificly - I have different types of users, with different model, all might be return when creating a new session. looking at rail casts #409 - ryan calls model.active_model_serializers.new - this does not work for me. is there any other way to get the seriailzer without knowing what model am I serializing?

I am using rails 4.2 and active_model_serializers 0.9.3

1

There are 1 answers

0
Ravindra On

use active_model_serializers gem

render :json => object, :serializer => ApiUser 

or you have an array of object than

render :json => objects, :each_serializer => ApiUser

create a file api_user.rb in serializers folder