Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating Post model and Paperclip interpolations

Updated Post model to use S3_CONFIG, and added timestamp to image name.

Updated timestamp method in Paperclip interpolations so that it returns
an integer instead of datetime string.
  • Loading branch information...
commit d31bb5faa2d6349ae333d51b3a91bb3c088a15fa 1 parent a1199f1
Doug Ramsay authored
View
8 app/models/post.rb
@@ -2,11 +2,11 @@ class Post < ActiveRecord::Base
has_attached_file :image,
:styles => {:large => "500x500", :medium => "250x250", :thumb => "100x100"},
:storage => 's3',
- :s3_credentials => YAML.load_file("#{RAILS_ROOT}/config/amazon_s3.yml")[RAILS_ENV],
- :bucket => "built-for-speed",
- :path => ":class/:id/:style.:extension"
+ :s3_credentials => S3_CONFIG,
+ :bucket => S3_CONFIG['bucket'],
+ :path => ":class/:id/:style_:timestamp.:extension"
def cloudfront_url( variant = nil )
image.url(variant).gsub( "http://s3.amazonaws.com/built-for-speed", CLOUDFRONT_DISTRIBUTION )
- end
+ end
end
View
2  vendor/plugins/paperclip/lib/paperclip/interpolations.rb
@@ -48,7 +48,7 @@ def url attachment, style
# Returns the timestamp as defined by the <attachment>_updated_at field
def timestamp attachment, style
- attachment.instance_read(:updated_at).to_s
+ attachment.instance_read(:updated_at).to_i
end
# Returns the RAILS_ROOT constant.
Please sign in to comment.
Something went wrong with that request. Please try again.