Mark CORS responses as uncacheable
[rails.git] / config / initializers / paperclip.rb
1 module Paperclip
2   class AssetUrlGenerator < UrlGenerator
3     include Sprockets::Helpers::IsolatedHelper
4     include Sprockets::Helpers::RailsHelper
5
6     def for(style_name, options)
7       url = super(style_name, options)
8
9       if url =~ /^\/assets\/(.*)$/
10         asset_path($1)
11       else
12         url
13       end
14     end
15   end
16 end
17
18 Paperclip::Attachment.default_options[:url] = "/attachments/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
19 Paperclip::Attachment.default_options[:path] = "#{ATTACHMENTS_DIR}/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
20 Paperclip::Attachment.default_options[:url_generator] = Paperclip::AssetUrlGenerator