Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
You can’t perform that action at this time.