Permalink
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...
Doug Ramsay
Doug Ramsay committed Jul 8, 2009
1 parent a1199f1 commit d31bb5faa2d6349ae333d51b3a91bb3c088a15fa
Showing with 5 additions and 5 deletions.
  1. +4 −4 app/models/post.rb
  2. +1 −1 vendor/plugins/paperclip/lib/paperclip/interpolations.rb
View
@@ -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
@@ -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.

0 comments on commit d31bb5f

Please sign in to comment.