Files
openfoodnetwork/app/serializers/api/admin/units_variant_serializer.rb
Luis Ramos 2d4326ded3 Replace empty? with blank? which is equivalent but a bit more resilient, returns false for nil
Present is not blank, so unless blank? becomes if present?
2020-07-01 14:08:07 +01:00

9 lines
238 B
Ruby

class Api::Admin::UnitsVariantSerializer < ActiveModel::Serializer
attributes :id, :full_name, :unit_value
def full_name
full_name = object.full_name
object.product.name + (full_name.blank? ? "" : ": #{full_name}")
end
end