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.11.0 app/models/deletable_attachment.rb
hackathon_manager-0.10.3 app/models/deletable_attachment.rb
hackathon_manager-0.10.2 app/models/deletable_attachment.rb
hackathon_manager-0.10.1 app/models/deletable_attachment.rb
hackathon_manager-0.10.0 app/models/deletable_attachment.rb
hackathon_manager-0.9.2 app/models/deletable_attachment.rb
hackathon_manager-0.9.1 app/models/deletable_attachment.rb
hackathon_manager-0.9.0 app/models/deletable_attachment.rb
hackathon_manager-0.8.2 app/models/deletable_attachment.rb
hackathon_manager-0.8.1 app/models/deletable_attachment.rb
hackathon_manager-0.8.0 app/models/deletable_attachment.rb
hackathon_manager-0.7.1 app/models/deletable_attachment.rb
hackathon_manager-0.7.0 app/models/deletable_attachment.rb
hackathon_manager-0.6.6 app/models/deletable_attachment.rb
hackathon_manager-0.6.5 app/models/deletable_attachment.rb
hackathon_manager-0.6.4 app/models/deletable_attachment.rb
hackathon_manager-0.6.3 app/models/deletable_attachment.rb
hackathon_manager-0.6.2 app/models/deletable_attachment.rb
hackathon_manager-0.6.1 app/models/deletable_attachment.rb
hackathon_manager-0.6.0 app/models/deletable_attachment.rb