Sha256: de9a8e15d5d0dc1bb3e17a73cc8b54d099e95c070731e7c2084bf9d4d2ef8b6a

Contents?: true

Size: 557 Bytes

Versions: 21

Compression:

Stored size: 557 Bytes

Contents

module Spina
  class Attachment < ApplicationRecord
    has_one_attached :file

    attr_accessor :_destroy

    scope :sorted, -> { order('created_at DESC') }

    def name
      file.filename.to_s
    end

    def content
      file if file.attached?
    end
    
    def present?
      signed_blob_id.present?
    end

    alias_method :old_update, :update
    def update(attributes)
      if attributes["_destroy"] == "1" && attributes["file"].blank?
        self.page_part.destroy
      else
        old_update(attributes)
      end
    end

  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
spina-2.12.0 app/models/spina/attachment.rb
spina-2.11.0 app/models/spina/attachment.rb
spina-2.10.0 app/models/spina/attachment.rb
spina-2.9.1 app/models/spina/attachment.rb
spina-2.9.0 app/models/spina/attachment.rb
spina-2.8.1 app/models/spina/attachment.rb
spina-2.8.0 app/models/spina/attachment.rb
spina-2.7.0 app/models/spina/attachment.rb
spina-2.6.2 app/models/spina/attachment.rb
spina-2.6.1 app/models/spina/attachment.rb
spina-2.6.0 app/models/spina/attachment.rb
spina-2.5.0 app/models/spina/attachment.rb
spina-2.4.0 app/models/spina/attachment.rb
spina-2.3.5 app/models/spina/attachment.rb
spina-2.3.4 app/models/spina/attachment.rb
spina-2.3.3 app/models/spina/attachment.rb
spina-2.3.2 app/models/spina/attachment.rb
spina-2.3.1 app/models/spina/attachment.rb
spina-2.3.0 app/models/spina/attachment.rb
spina-2.2.0 app/models/spina/attachment.rb