Class: Dscf::Marketplace::ProductSerializer

Inherits:
ActiveModel::Serializer
  • Object
show all
Defined in:
app/serializers/dscf/marketplace/product_serializer.rb

Instance Method Summary collapse

Instance Method Details

#image_urlsObject



20
21
22
23
24
25
26
27
28
# File 'app/serializers/dscf/marketplace/product_serializer.rb', line 20

def image_urls
  if object.images.attached?
    ActiveStorage::Current.set(url_options: {host: "dscf.bitscollege.edu.et", protocol: "https", script_name: "/api/marketplace"}) do
      object.images.map(&:url)
    end
  else
    []
  end
end

#thumbnail_urlObject



12
13
14
15
16
17
18
# File 'app/serializers/dscf/marketplace/product_serializer.rb', line 12

def thumbnail_url
  if object.thumbnail.attached?
    ActiveStorage::Current.set(url_options: {host: "dscf.bitscollege.edu.et", protocol: "https", script_name: "/api/marketplace"}) do
      object.thumbnail.url
    end
  end
end