Skip to content

Instantly share code, notes, and snippets.

@hito-asa
Forked from nakaearth/gist:5097524
Last active December 15, 2015 16:39
Show Gist options
  • Save hito-asa/5290947 to your computer and use it in GitHub Desktop.
Save hito-asa/5290947 to your computer and use it in GitHub Desktop.
class Stamp < ActiveRecord::Base
Paperclip.interpolates :img_dir_num do |attachment, style|
(attachment.instance.id * 0.01).to_i
end
Paperclip.interpolates :filename do |attachment, style|
attachment.instance.id.to_s + ".png"
end
if Rails.env.production?
S3_CREDENTIALS = {access_key_id: ENV['S3_ACCESS_KEY_ID'], secret_access_key: ENV['S3_SECRET_KEY'], bucket: "hoge-bucket"}
end
if Rails.env.production?
has_attached_file :stamp,
storage: :s3,
s3_credentials: S3_CREDENTIALS,
styles: {stamps_s: "100x100>", stamps:"350x350>"},
url: ":s3_domain_url",
path: "stamps/:style/:img_dir_num/:filename"
else
has_attached_file :stamp,
url: "/:style/:img_dir_num/:filename" ,
styles: {stamps_s: "100x100>", stamps:"350x350>"}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment