scinote-web/app/serializers/api/v2/asset_serializer.rb
wandji 465c8d1f80
Unify API step and result elements controllers implementation and types [SCI-9907] (#6854)
* Unify api step and result elements controllers implementation and types [SCI-9907]

* Update wrong serializer types [SCI-9907]

* Rename result and step text types [SCI-9907]

* Combine result and step assets serializer [SCI-9907]
2024-01-08 10:31:14 +01:00

23 lines
489 B
Ruby

# frozen_string_literal: true
module Api
module V2
class AssetSerializer < ActiveModel::Serializer
type :attachments
attributes :id, :file_name, :file_size, :file_type, :file_url
include TimestampableModel
def file_type
object.content_type
end
def file_url
if object.file&.attached?
Rails.application.routes.url_helpers.rails_blob_path(object.file, disposition: 'attachment')
end
end
end
end
end