Sha256: 2d8399ea3c62907d4e71b77202c6c88a1e87e48fde45d82db2acb3d95d5a441e

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    module AttachmentMethods
      private

      def build_attachment
        @attachment = Attachment.new(
          title: @form.attachment.title,
          file: @form.attachment.file,
          attached_to: @attached_to
        )
      end

      def attachment_invalid?
        if attachment.invalid? && attachment.errors.has_key?(:file)
          @form.attachment.errors.add :file, attachment.errors[:file]
          true
        end
      end

      def create_attachment
        attachment.attached_to = @attached_to
        attachment.save!
      end

      def process_attachments?
        @form.attachment && @form.attachment.file.present?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-initiatives-0.22.0 app/commands/decidim/initiatives/attachment_methods.rb