Sha256: 6b5cfd821ecba7a3e782365daaea7b94e3a5845f92b09ad4bd9cb29ca12ef973

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 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.is_a?(String) && data.strip.end_with?("==")
            super(Carrierwave::Base64::Base64StringIO.new(data.strip))
          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.2 lib/carrierwave/base64/orm/activerecord.rb