Sha256: ec0975ae21d392ebaef34d04426470bba1cc83e6e0e40feaacb0ca3e76c50a4f

Contents?: true

Size: 615 Bytes

Versions: 17

Compression:

Stored size: 615 Bytes

Contents

require 'carrierwave/mongoid'

module CarrierWave

  module Mongoid

    def mount_uploader_with_localization(column, uploader=nil, options={}, &block)
      mount_uploader_without_localization(column, uploader, options, &block)

      define_method(:read_uploader) do |name|
        # puts "read_uploader #{name} / #{read_attribute(name.to_sym).inspect}" # DEBUG

        value = read_attribute(name.to_sym)
        unless value.nil?
          self.class.fields[name.to_s].deserialize(value)
        else
          nil
        end
      end
    end

    alias_method_chain :mount_uploader, :localization
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
custom_fields-2.1.0 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.1.0.rc2 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.1.0.rc1 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.1.0.rc lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc13 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc12 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc11 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc10 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc9 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc8 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc7 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc6 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc5 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc4 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc3 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc2 lib/custom_fields/extensions/carrierwave.rb
custom_fields-2.0.0.rc1 lib/custom_fields/extensions/carrierwave.rb