Skip to content

Instantly share code, notes, and snippets.

@sofadesign
Created March 2, 2010 09:00
Show Gist options
  • Save sofadesign/319364 to your computer and use it in GitHub Desktop.
Save sofadesign/319364 to your computer and use it in GitHub Desktop.
# Paperclip attachment, with sorting and special convert options
class PageAsset < ActiveRecord::Base
acts_as_list :scope => :page
has_attached_file :asset,
:styles => {
:small => "110x82#",
:thumb => "150x90#",
:large => "460x345>",
:original => "1600x1200>"
},
:convert_options => {
:large => '-background white -gravity center -extent 460x345'
} # 460x350, keeping ratio, filling extra margin with blank
validates_attachment_presence :asset, :message => "Image requise."
validates_attachment_content_type :asset,
:content_type => ['image/pjpeg', 'image/jpeg', 'image/png'],
:message => "doit être une image JPEG ou PNG"
validates_attachment_size :asset, :less_than => 4.megabytes,
:message => "doit être comprise entre :min et :max octets"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment