Module: CarrierWave::Mongoid

Defined in:
lib/custom_fields/extensions/carrierwave.rb

Instance Method Summary collapse

Instance Method Details

#mount_uploader_with_localization(column, uploader = nil, options = {}, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/custom_fields/extensions/carrierwave.rb', line 7

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].demongoize(value)
    else
      nil
    end
  end
end