Sha256: 9aaf8b83206a8ce39a20a27db2ab9de221918e2eeb47da3c2fa4a9b8e4bbdcb4

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

require "active_record"

module Carrierwave
  module Base64
    module ActiveRecord
      def mount_base64_uploader(attribute, uploader_class)
        mount_uploader attribute, uploader_class

        define_method "#{attribute}=" do |data|
          if data.present? && data.end_with?("==")
            super(Carrierwave::Base64::Base64StringIO.new(data)) if data.end_with?("==")
          else
            super(data)
          end
        end
      end
    end
  end
end

ActiveRecord::Base.extend Carrierwave::Base64::ActiveRecord

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave-base64-1.0 lib/carrierwave/base64/orm/activerecord.rb