Sha256: 8d30d853f506125c3abc2096f85aa6f9e87279471bc664bedda94df614b78d57

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

if product.categories.any?
  json.categories do
    json.data do
      json.array! product.categories do |category|
        json.type 'categories'
        json.id category.id
      end
    end
  end
end

if product.stores.any?
  json.stores do
    json.data do
      json.array! product.stores do |store|
        json.type 'stores'
        json.id store.id
      end
    end
  end
end

if product.assets.where(store: current_store).any?
  json.assets do
    json.array! product.assets.where(store: current_store) do |asset|
      json.type 'assets'
      json.id asset.id
    end
  end
end

if product.configurable_products.any?
  json.configurable_products do
    json.array! product.configurable_products do |configurable_product|
      json.type 'products'
      json.id configurable_product.id
    end
  end
end

if product.simple_products.any?
  json.simple_products do
    json.array! product.simple_products do |simple_product|
      json.type 'products'
      json.id simple_product.id
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/views/gemgento/api/v1/products/_relationships.json.jbuilder