Skip to content

Instantly share code, notes, and snippets.

@nhc
Last active December 17, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhc/5620663 to your computer and use it in GitHub Desktop.
Save nhc/5620663 to your computer and use it in GitHub Desktop.
For when you don't have imagemagick on your development machine for whatever reason. This goes in your rails model and only applies styles if your in the Production environment. Also uses some stored S3 credentials for AWS S3 storage.
class ModelName < ActiveRecord::Base
has_attached_file :avatar, :styles => lambda { |attachment| ( Rails.env.production? ) ? { :medium => "104x104", :small => "60x60" } : {} }, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => "/:style/:id/:filename"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment