Skip to content

Instantly share code, notes, and snippets.

@vortizhe
Last active December 20, 2015 14:39
Show Gist options
  • Save vortizhe/6148350 to your computer and use it in GitHub Desktop.
Save vortizhe/6148350 to your computer and use it in GitHub Desktop.
config.to_prepare do
::Dragonfly[:images].configure do |c|
c.define_url do |app, job, opts|
thumb = Thumb.find_by_job(job.serialize)
if thumb
app.datastore.url_for(thumb.uid)
app.cache_duration = 3600*24*7
else
app.server.url_for(job)
app.cache_duration = 3600
end
end
c.server.before_serve do |job, env|
uid = job.store
Thumb.create!( :uid => uid, :job => job.serialize )
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment