Paperclip.interpolates(:product_code) do |attachment, style| attachment.instance.product.code end Paperclip.interpolates(:size) do |attachment, style| attachment.instance.size end Paperclip.interpolates(:timestamp) do |attachment, style| attachment.instance_read(:updated_at).in_time_zone(7).strftime("%s") end Paperclip.interpolates(:s3_url) do |attachment, style| path = attachment.path(style) "#{attachment.s3_protocol}://#{Settings.uploadable_asset_host % (path.hash % 4)}/#{path.gsub(%r{^/}, "")}" end