]> git.openstreetmap.org Git - rails.git/blob - config/initializers/paperclip.rb
Highlight search results when the mouse is over them
[rails.git] / config / initializers / paperclip.rb
1 module Paperclip
2   class AssetUrlGenerator < UrlGenerator
3     include Sprockets::Rails::Helper
4
5     def for(style_name, options)
6       url = super(style_name, options)
7
8       if url =~ /^\/assets\/(.*)$/
9         asset_path($1)
10       else
11         url
12       end
13     end
14   end
15 end
16
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))
20   end
21 end
22
23 Paperclip::Attachment.default_options[:url] = "/attachments/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
24 Paperclip::Attachment.default_options[:path] = "#{ATTACHMENTS_DIR}/:class/:attachment/:id_partition/:style/:fingerprint.:extension"
25 Paperclip::Attachment.default_options[:url_generator] = Paperclip::AssetUrlGenerator