Last active
August 14, 2020 14:16
-
-
Save jpesce/1f727104f9d48d30ebcbb9a602271fca to your computer and use it in GitHub Desktop.
[Serializer] Prints serializer on console #Ruby #Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # default serializer | |
| ActiveModelSerializers::SerializableResource.new(record_or_collection).as_json | |
| # custom serializer | |
| ActiveModel::SerializableResource.new(record, serializer: CustomSerializer).as_json | |
| ActiveModel::SerializableResource.new(collection, each_serializer: CustomSerializer).as_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment