Sha256: b812542b6d61d5fae85f917225af9a211b8d9ca32e32fe2803ce37921458e504

Contents?: true

Size: 761 Bytes

Versions: 5

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module Admin
    module UploaderResponses
      extend ActiveSupport::Concern

      def successful_uploader_response(file:, status: :created)
        message = Alchemy.t(:upload_success,
          scope: [:uploader, file.class.model_name.i18n_key],
          name: file.name)

        {
          json: {message: message},
          status: status
        }
      end

      def failed_uploader_response(file:)
        message = Alchemy.t(:upload_failure,
          scope: [:uploader, file.class.model_name.i18n_key],
          error: file.errors[:file].join,
          name: file.name)

        {
          json: {message: message},
          status: :unprocessable_entity
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 app/controllers/concerns/alchemy/admin/uploader_responses.rb
alchemy_cms-7.3.3 app/controllers/concerns/alchemy/admin/uploader_responses.rb
alchemy_cms-7.3.2 app/controllers/concerns/alchemy/admin/uploader_responses.rb
alchemy_cms-7.3.1 app/controllers/concerns/alchemy/admin/uploader_responses.rb
alchemy_cms-7.3.0 app/controllers/concerns/alchemy/admin/uploader_responses.rb