Created
June 20, 2014 07:18
-
-
Save jbmyid/2e0405f1540154df7a6e 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
process :get_geometry | |
def geometry | |
@geometry | |
end | |
def get_geometry | |
if (@file) | |
img = ::Magick::Image::read(@file.file).first | |
@geometry = [ img.columns, img.rows ] | |
end | |
end | |
#User class | |
validate :validate_minimum_image_size | |
def validate_minimum_image_size | |
geometry = self.image.geometry | |
if (! geometry.nil?) | |
self.width = geometry[0] | |
self.height = geometry[1] | |
end | |
unless (self.width == 320 && self.height == 480) || (self.width == 640 && self.height == 960) | |
errors.add :base, "Naughty you... iPhone designs should be 320px x 480px or 640px x 960px." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment