Sha256: e8877513e43793b8172b1169ddd303e9a7484e2fe7334e32c75961ed6448b4be

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

require "active_record"

module Carrierwave
  module Base64
    module ActiveRecord
      def mount_base64_uploader(attribute, uploader_class, options = {})
        mount_uploader attribute, uploader_class, options

        define_method "#{attribute}=" do |data|
          if data.present? && data.is_a?(String) && data.strip.start_with?("data")
            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

2 entries across 2 versions & 1 rubygems

Version Path
carrierwave-base64-1.6 lib/carrierwave/base64/orm/activerecord.rb
carrierwave-base64-1.5 lib/carrierwave/base64/orm/activerecord.rb