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

Version Path
hackathon_manager-0.14.1 app/models/deletable_attachment.rb
hackathon_manager-0.14.0 app/models/deletable_attachment.rb
hackathon_manager-0.13.12 app/models/deletable_attachment.rb
hackathon_manager-0.13.11 app/models/deletable_attachment.rb
hackathon_manager-0.13.10 app/models/deletable_attachment.rb
hackathon_manager-0.13.9 app/models/deletable_attachment.rb
hackathon_manager-0.13.8 app/models/deletable_attachment.rb
hackathon_manager-0.13.7 app/models/deletable_attachment.rb
hackathon_manager-0.13.6 app/models/deletable_attachment.rb
hackathon_manager-0.13.5 app/models/deletable_attachment.rb
hackathon_manager-0.13.4 app/models/deletable_attachment.rb
hackathon_manager-0.13.3 app/models/deletable_attachment.rb
hackathon_manager-0.13.2 app/models/deletable_attachment.rb
hackathon_manager-0.13.1 app/models/deletable_attachment.rb
hackathon_manager-0.13.0 app/models/deletable_attachment.rb
hackathon_manager-0.12.2 app/models/deletable_attachment.rb
hackathon_manager-0.12.1 app/models/deletable_attachment.rb
hackathon_manager-0.12.0 app/models/deletable_attachment.rb
hackathon_manager-0.11.2 app/models/deletable_attachment.rb
hackathon_manager-0.11.1 app/models/deletable_attachment.rb