Add paperclip path to uploaders

This commit is contained in:
Karina Kwiatek 2020-05-02 13:04:23 +01:00 committed by Dominik M. Kwiatek
parent 76161029e8
commit 6f0d4971fb
2 changed files with 9 additions and 2 deletions

View file

@ -11,6 +11,10 @@ class ProfileHeaderUploader < CarrierWave::Uploader::Base
"/system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" "/system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end end
def paperclip_path
"users/:attachment/:id_partition/:style/:basename.:extension"
end
# Provide a default URL as a default if there hasn't been a file uploaded: # Provide a default URL as a default if there hasn't been a file uploaded:
def default_url(*args) def default_url(*args)
# For Rails 3.1+ asset pipeline compatibility: # For Rails 3.1+ asset pipeline compatibility:

View file

@ -11,13 +11,16 @@ class ProfilePictureUploader < CarrierWave::Uploader::Base
"/system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" "/system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end end
def paperclip_path
"users/:attachment/:id_partition/:style/:basename.:extension"
end
# Provide a default URL as a default if there hasn't been a file uploaded: # Provide a default URL as a default if there hasn't been a file uploaded:
def default_url(*args) def default_url(*args)
# For Rails 3.1+ asset pipeline compatibility: # For Rails 3.1+ asset pipeline compatibility:
# ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
"/images/ "/images/" + [version_name, "no_avatar.png"].compact.join('/')
" + [version_name, "no_avatar.png"].compact.join('/')
end end
version :large do version :large do