Created
August 8, 2009 16:56
-
-
Save mrrooijen/164456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inside the model.rb | |
has_attached_file :image, | |
:url => "/assets/images/:style/:id.:basename.:extension", | |
:path => ":rails_root/public/assets/images/:style/:id.:basename.:extension", | |
:styles => { | |
:small => '50x45#', | |
:medium => '150x150', | |
:large => '300x300' | |
} | |
# Validations | |
validates_attachment_presence :image, :message => "You are required to select an image." | |
validates_attachment_size :image, :less_than => 2.megabytes, :message => "must be less than 500 kilobytes." | |
validates_attachment_content_type :image, :content_type => ['image/jpg', 'image/jpeg','image/gif','image/png','image/pjpeg','image/x-png'], :message => "Must be JPG PNG or GIF." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment