mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
465c8d1f80
* 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]
23 lines
489 B
Ruby
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
|