Skip to content

Instantly share code, notes, and snippets.

@tiagopog
Created April 9, 2015 14:53
Show Gist options
  • Save tiagopog/b5c18f6e43e966cff085 to your computer and use it in GitHub Desktop.
Save tiagopog/b5c18f6e43e966cff085 to your computer and use it in GitHub Desktop.
Avatar concern.
# 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