Sha256: d7abfefca1b0280eb2685ff9634c0fd75f087f62bb8dbcf3113b8e0b9e9f7e1b
Contents?: true
Size: 697 Bytes
Versions: 6
Compression:
Stored size: 697 Bytes
Contents
module Spina class Attachment < ApplicationRecord has_one_attached :file has_one :page_part, as: :page_partable has_many :structure_parts, as: :structure_partable has_and_belongs_to_many :attachment_collections, join_table: 'spina_attachment_collections_attachments' attr_accessor :_destroy scope :sorted, -> { order('file ASC') } def name file.filename.to_s end def content file if file.attached? 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
6 entries across 6 versions & 1 rubygems