Created
February 28, 2016 19:48
-
-
Save kitlangton/9cc0428b8fdc0ea3b262 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Photo < ActiveRecord::Base | |
has_many :profiles | |
has_attached_file :photo, :styles => { :medium => "300x300", :large => "500x500", :thumb => "100x100" }, :s3_host_name => 's3-us-west-2.amazonaws.com' | |
validates_attachment_content_type :photo, :content_type => /\Aimage\/.*\Z/ | |
validates_with AttachmentSizeValidator, attributes: :photo, less_than: 5.megabytes | |
validates_attachment_presence :photo, presence: true | |
def photo_from_url(url) | |
self.photo = open(url) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment