Skip to content

Instantly share code, notes, and snippets.

@nakaearth
Last active December 14, 2015 13:59
Show Gist options
  • Save nakaearth/5097524 to your computer and use it in GitHub Desktop.
Save nakaearth/5097524 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
@hito-asa
Copy link

hito-asa commented Apr 2, 2013

これもスペーシングだけ
https://gist.github.com/hito-asa/5290947

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment