Fix rubocop warning
This commit is contained in:
parent
6dd451c7ee
commit
d2d3f2c9fd
1 changed files with 10 additions and 10 deletions
|
@ -1,17 +1,17 @@
|
|||
namespace "storage" do
|
||||
task :upgrade_avatars => :environment do
|
||||
User.active.where.not(:image_file_name => nil).in_batches.each_record do |user|
|
||||
unless user.avatar.attached?
|
||||
io = File.open(user.image.path)
|
||||
filename = user.image.original_filename
|
||||
content_type = if user.image.content_type.nil?
|
||||
MimeMagic.by_magic(io)&.type
|
||||
else
|
||||
user.image.content_type
|
||||
end
|
||||
next if user.avatar.attached?
|
||||
|
||||
user.avatar.attach(:io => io, :filename => filename, :content_type => content_type)
|
||||
end
|
||||
io = File.open(user.image.path)
|
||||
filename = user.image.original_filename
|
||||
content_type = if user.image.content_type.nil?
|
||||
MimeMagic.by_magic(io)&.type
|
||||
else
|
||||
user.image.content_type
|
||||
end
|
||||
|
||||
user.avatar.attach(:io => io, :filename => filename, :content_type => content_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue