Skip to content

Instantly share code, notes, and snippets.

@alexkojin
Created March 20, 2010 05:48
Show Gist options
  • Save alexkojin/338503 to your computer and use it in GitHub Desktop.
Save alexkojin/338503 to your computer and use it in GitHub Desktop.
class Photo < ActiveRecord::Base
has_attached_file :file,
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3_credentials.yml",
:bucket => 'hdphotos',
:path => ":uid/:id/:token_:style.:extension",
:styles => {:thumb => '189x189#', :cover => '379x379#', :hd => '912x720>'},
:convert_options => { :all => '-strip -colorspace RGB' }
belongs_to :user
belongs_to :album, :counter_cache => true
after_post_process :define_sizes
private
def define_sizes
self.thumb_file_size = self.file.queued_for_write[:thumb].size
self.cover_file_size = self.file.queued_for_write[:cover].size
self.hd_file_size = self.file.queued_for_write[:hd].size
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment