Skip to content

Instantly share code, notes, and snippets.

@jpesce
Last active August 14, 2020 14:16
Show Gist options
  • Select an option

  • Save jpesce/1f727104f9d48d30ebcbb9a602271fca to your computer and use it in GitHub Desktop.

Select an option

Save jpesce/1f727104f9d48d30ebcbb9a602271fca to your computer and use it in GitHub Desktop.
[Serializer] Prints serializer on console #Ruby #Rails
# 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