2 class AssetUrlGenerator < UrlGenerator
3 include Sprockets::Rails::Helper
5 def for(style_name, options)
6 url = super(style_name, options)
8 if url =~ %r{^/assets/(.*)$}
9 asset_path(Regexp.last_match(1))
17 Rails.application.config.after_initialize do |_app|
18 Paperclip::AssetUrlGenerator::VIEW_ACCESSORS.each do |attr|
19 Paperclip::AssetUrlGenerator.send("#{attr}=", ActionView::Base.send(attr))
23 Paperclip::Attachment.default_options[:url] = "/attachments/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
24 Paperclip::Attachment.default_options[:path] = "#{Settings.attachments_dir}/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
25 Paperclip::Attachment.default_options[:url_generator] = Paperclip::AssetUrlGenerator