Sha256: 65a652f6d3e5d8fa8e511f6bf48e0f55f4c3dfc6eee90a219f6a6b22da9be0ad
Contents?: true
Size: 722 Bytes
Versions: 26
Compression:
Stored size: 722 Bytes
Contents
module Spina class Attachment < ActiveRecord::Base has_one :page_part, as: :page_partable has_and_belongs_to_many :attachment_collections, join_table: 'spina_attachment_collections_attachments' attr_accessor :_destroy scope :sorted, -> { order('created_at DESC') } scope :file_attached, -> { where('file IS NOT NULL') } mount_uploader :file, FileUploader def name file.file.try(:filename) end alias_method :old_update_attributes, :update_attributes def update_attributes(attributes) if attributes["_destroy"] == "1" && attributes["file"].blank? self.page_part.destroy else old_update_attributes(attributes) end end end end
Version data entries
26 entries across 26 versions & 1 rubygems