mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Serialise tag_list only for variant overrides
Don't try to call tag_list on just variants since that will fail. Normally, all variants of `current_order` should be extended to VariantOverrides of the current order cycle. But in development environment, it can happen that the variants are reloaded without being extended again.
This commit is contained in:
committed by
Rob Harrington
parent
e1b40142b8
commit
fe7bd5e2cd
@@ -1,7 +1,6 @@
|
||||
class Api::VariantSerializer < ActiveModel::Serializer
|
||||
attributes :id, :is_master, :count_on_hand, :name_to_display, :unit_to_display
|
||||
attributes :options_text, :on_demand, :price, :fees, :price_with_fees, :product_name
|
||||
attributes :tag_list
|
||||
|
||||
def price
|
||||
object.price
|
||||
@@ -23,4 +22,8 @@ class Api::VariantSerializer < ActiveModel::Serializer
|
||||
def product_name
|
||||
object.product.name
|
||||
end
|
||||
|
||||
def tag_list
|
||||
object.tag_list if object.is_a? VariantOverride
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user