Chore: Switch from Carrierwave to ActiveStorage (#393)
This commit is contained in:
18
app/models/concerns/avatarable.rb
Normal file
18
app/models/concerns/avatarable.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Avatarable
|
||||
extend ActiveSupport::Concern
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
included do
|
||||
has_one_attached :avatar
|
||||
end
|
||||
|
||||
def avatar_url
|
||||
if avatar.attached? && avatar.representable?
|
||||
url_for(avatar.representation(resize: '250x250'))
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user