Skip to content

Instantly share code, notes, and snippets.

@dimiro1
Created February 19, 2010 11:42
Show Gist options
  • Save dimiro1/308648 to your computer and use it in GitHub Desktop.
Save dimiro1/308648 to your computer and use it in GitHub Desktop.
class Photo < ActiveRecord::Base
belongs_to :album
named_scope :covers, :conditions => {:cover => true}
has_attached_file :image,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/amazon_s3.yml",
:path => ":attachment/:id/:style/:basename.:extension",
:styles => {
:original => {:geometry => "500x375>", :processors => [:thumbnail, :watermark], :quality => :better },
:thumb => {:geometry => "350x270>", :processors => [:thumbnail]}
}
validates_attachment_content_type :image,
:content_type => [ 'image/jpeg',
'image/pjpeg', # for progressive jpeg (IE mine-type for regular jpeg)
'image/jpg',
'image/x-png', # IE mine-type for PNG
'image/png',
'image/gif' ]
validates_attachment_size :image, :less_than => 2.megabytes
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment