Skip to content

Instantly share code, notes, and snippets.

@braidn
Last active August 29, 2015 14:06
Show Gist options
  • Save braidn/c97ee27aa40ed8067ace to your computer and use it in GitHub Desktop.
Save braidn/c97ee27aa40ed8067ace to your computer and use it in GitHub Desktop.
Paperclip Initializer
if ENV['USE_S3'] == 'true'
Paperclip::Attachment.default_options[:storage] = :fog
Paperclip::Attachment.default_options[:fog_credentials] = { provider: "AWS", aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'] }
Paperclip::Attachment.default_options[:fog_directory] = ENV['FOG_BUCKET']
Paperclip::Attachment.default_options[:path] = '/app/public/assets/products/:id/:style/:basename.:extension'
Paperclip::Attachment.default_options[:fog_host] = ENV['S3_HOST_ALIAS']
Paperclip::Attachment.default_options[:url] = ':s3_alias_url'
Spree::Image.attachment_definitions[:attachment][:path] = 'public/assets/products/:id/:style/:basename.:extension'
else
Paperclip::Attachment.default_options[:storage] = :fog
Paperclip::Attachment.default_options[:fog_credentials] = {:provider => "Local", :local_root => "#{Rails.root}/public"}
Paperclip::Attachment.default_options[:fog_directory] = ""
Paperclip::Attachment.default_options[:fog_host] = "http://localhost:3000"
Paperclip::Attachment.default_options[:path] = 'app/public/assets/products/:id/:style/:basename.:extension'
Spree::Image.attachment_definitions[:attachment][:path] = 'system/:attachment/:id/:style/:filename'
end
Spree::Image.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode('{"mini":"48x48\u003E","option":"260x120\u003E", "product":"1155x525\u003E"}').symbolize_keys!
Spree::Image.attachment_definitions[:attachment][:default_style] = 'product'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment