Sha256: 2ed54ef4e1142a8ac28f7c7645c3cb899b622b5448a25f9b73d8631f6accea6a
Contents?: true
Size: 500 Bytes
Versions: 63
Compression:
Stored size: 500 Bytes
Contents
# This needs to be included after all has_attached_file statements in a class module DeletableAttachment extend ActiveSupport::Concern included do attachment_definitions.keys.each do |name| attr_accessor :"delete_#{name}" before_validation { send(name).destroy if send("delete_#{name}") == '1' } define_method :"delete_#{name}=" do |value| instance_variable_set :"@delete_#{name}", value send("#{name}_file_name_will_change!") end end end end
Version data entries
63 entries across 63 versions & 1 rubygems