Skip to content

Instantly share code, notes, and snippets.

@sharpmachine
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save sharpmachine/178778cfb6d536dfa40d to your computer and use it in GitHub Desktop.

Select an option

Save sharpmachine/178778cfb6d536dfa40d to your computer and use it in GitHub Desktop.
Capture screenshot and store it to Amazon s3 - via Carrierwave, Fog and Phantomjs
class Model < ActiveRecord::Base
before_save :website_screenshot
mount_uploader :screenshot, ScreenshotUploader
def website_screenshot
file = 'app/assets/images/website_screenshot.png'
system 'phantomjs app/assets/javascripts/vendors/rasterize.js ' + website + ' ' + file
self.screenshot = File.open(File.join(Rails.root, file))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment