It's an initialization process
you can create a paperclip.rb in config/initializers/
mine has 2 interpolations
# a more complex one (I have different types of assets)
Paperclip.interpolates :content_type_extension do |attachment,
style_name|
case
when ((style = attachment.styles[style_name]) && !style
[:format].blank?) then style[:format]
when attachment.instance.video? && style_name.to_s == 'transcoded'
then 'flv'
when attachment.instance.audio? && style_name.to_s == 'thumb' then
'jpg'
when attachment.instance.video? && style_name.to_s != 'original'
then 'jpg'
else
File.extname(attachment.original_filename).gsub(/^\.+/, "")
end
end
#or a more simpler for user avatar attachment
Paperclip.interpolates :username do |attachment, style_name|
attachment.instance.username
end