-
Notifications
You must be signed in to change notification settings - Fork 423
Open
Description
Hey guys 🖖
Seems like there's a pretty big issue with custom attributes definition that makes this gem a little bit unusable in some scenarios.
I've a following serializer in my application
class ProductSerializer
include FastJsonapi::ObjectSerializer
set_type :product
attributes :name, :description, :price, :currency, :display_price
attribute :backorderable do |product|
product.variants_including_master.any?(&:backorderable?)
end
end
Here's the response I get
{
"data": {
"id": "3",
"type": "product",
"attributes": null
}
}
It seems there's no way to use a block inside of an attribute do / end
block without nullifying the attributes hash.
I've tried changing any?(&:backorderable)
to any? { |variant| variant.backorderable? }
but it produces the same result.
Changing block contents to product.variants_including_master.first.backorderable?
for the sake of testing works though and returns the appropriate response.
Metadata
Metadata
Assignees
Labels
No labels