Closed gkpacker closed 4 years ago
Hello!
I'm trying to serialize my product object but it responds to size, so it is treated as a collection in:
size
def is_collection?(resource, force_is_collection = nil) return force_is_collection unless force_is_collection.nil? resource.respond_to?(:size) && !resource.respond_to?(:each_pair) end
and ends up breaking the code:
[1] pry(#<Api::V1::ProductsController>)> ProductSerializer.new(@product).serializable_hash NoMethodError: undefined method `each' for #<Product:0x00007f8f563881b8>
It is intended to be that way?
Workaround:
ProductSerializer.new(@product, is_collection: false).serializable_hash
Thanks!
This is now merged in the forked project!
Nice, I'll close the issue!
Hello!
I'm trying to serialize my product object but it responds to
size
, so it is treated as a collection in:and ends up breaking the code:
It is intended to be that way?
Workaround:
Thanks!