openstreetmap-website/config/initializers/paperclip.rb
2013-09-21 11:35:45 +01:00

19 lines
621 B
Ruby

module Paperclip
class AssetUrlGenerator < UrlGenerator
include Sprockets::Rails::Helper
def for(style_name, options)
url = super(style_name, options)
if url =~ /^\/assets\/(.*)$/
asset_path($1)
else
url
end
end
end
end
Paperclip::Attachment.default_options[:url] = "/attachments/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
Paperclip::Attachment.default_options[:path] = "#{ATTACHMENTS_DIR}/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
Paperclip::Attachment.default_options[:url_generator] = Paperclip::AssetUrlGenerator