BigW Consortium Gitlab

avatar_uploader.rb 388 Bytes
Newer Older
1
class AvatarUploader < CarrierWave::Uploader::Base
2 3
  include UploaderHelper

4 5 6 7 8 9 10 11 12 13 14
  storage :file

  after :store, :reset_events_cache

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  def reset_events_cache(file)
    model.reset_events_cache if model.is_a?(User)
  end
15 16 17 18

  def exists?
    model.avatar.file && model.avatar.file.exists?
  end
19
end