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:
Maikel Linke
2016-07-27 15:58:54 +10:00
committed by Rob Harrington
parent e1b40142b8
commit fe7bd5e2cd

View File

@@ -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