In my controller, i have two methods that render a json, i want to use differents serializer for each method. how can i do it. i've tried : render json: response ,each_serialiser: SerializerName in every methods by it's doesn't work
Asked
Active
Viewed 1,878 times
1
-
Possible duplicate of [How to implement multiple different serializers for same model using ActiveModel::Serializers?](http://stackoverflow.com/questions/12485404/how-to-implement-multiple-different-serializers-for-same-model-using-activemodel) – Saravanabalagi Ramachandran Nov 28 '16 at 07:40
2 Answers
0
render json: @response, serializer: SerializerName
should do the trick.
-
-
no i didn't added this line, but when i don't specify which serializer, it works with calling the serializer that have the same name then the model. now i've added a new serializer with a different name and i want to call it for an other action. – Maryeme Alaoui Sep 17 '14 at 18:51
0
you should create two serializer for each response use one of them and rename the response.

Marouane Lanouari
- 449
- 5
- 16