Created
April 9, 2015 14:53
-
-
Save tiagopog/b5c18f6e43e966cff085 to your computer and use it in GitHub Desktop.
Avatar concern.
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
# rails g paperclip {{model_name}} avatar && rake db:migrate | |
module Avatar | |
extend ActiveSupport::Concern | |
included do | |
avatar_options = WMR::Constants::AVATAR_OPTIONS | |
if Rails.env.production? | |
avatar_options.merge!(WMR::Constants::S3_CREDENTIALS) | |
end | |
has_attached_file :avatar, avatar_options | |
validates_attachment :avatar, content_type: { content_type: /\Aimage\/.*\Z/ }, | |
size: { in: 0..10.megabytes } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment