Added multi-storage (AWS/S3) functionality to attachments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
require 'attachment' require 'has_attachment/storage' module HasAttachment def self.included(base) base.extend ClassMethods end module ClassMethods def has_attachment(options = {}) has_one :attachment, options.merge(:as => :attachable) include InstanceMethods alias_method_chain :attachment=, :validation end end module InstanceMethods def attachment_with_validation=(value) self.attachment_without_validation = Attachment.parse(value) end end end ActiveRecord::Base.class_eval do include HasAttachment end |
|---|