Class: CustomFields::Types::File::FileUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Defined in:
lib/custom_fields/types/file.rb

Instance Method Summary collapse

Instance Method Details

#set_size_in_modelObject



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/custom_fields/types/file.rb', line 90

def set_size_in_model
  size_field_name = :"#{mounted_as}_size"

  if model.respond_to?(size_field_name)
    is_localized  = model.fields[mounted_as.to_s].options[:localize]
    key           = is_localized ? ::Mongoid::Fields::I18n.locale.to_s : 'default'
    values        = model.send(size_field_name)

    values[key] = file.size
  end
end