Skip to content

Instantly share code, notes, and snippets.

@rla
Forked from jqr/nginx.conf
Created December 2, 2013 14:13
Show Gist options
  • Save rla/7750041 to your computer and use it in GitHub Desktop.
Save rla/7750041 to your computer and use it in GitHub Desktop.
# Nginx cache busting rewriter, best used on assets that have long-lived expires.
#
# Rewrites like so:
# blah.com/release_ab2ea212312.../file.css => blah.com/file.css
#
location ~ ^/release_(.*?)/ {
rewrite ^/release_(.*?)/(.*)$ /$2 last;
}
# A paperclip initializer, place in config/initializers/
Paperclip::Attachment.interpolations[:release_path] =
lambda do |attachment, style|
unless AssetVersion.version.blank?
"/release_#{AssetVersion.version}"
end
end
class SomeModel < ActiveRecord::Base
has_attached_file :image, {
:styles => {
:thumb => "100x100",
},
:url => ":release_path/attachments/:class/:attachment/:id/:style/:basename.:extension",
:path => ":rails_root/public/attachments/:class/:attachment/:id/:style/:basename.:extension",
:default_url => "/images/:class/:attachment/missing_:style.png",
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment