From e76604331be70c12ff2033eab929f212832b2473 Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Tue, 29 Oct 2024 23:05:30 +0900 Subject: [PATCH] Hotfix again: Directly pass upload file to avatar creation --- app/controllers/users_controller.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f50b1dffd4..cc99b18936 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -163,17 +163,14 @@ def upload_avatar thumbnail_json = params.require(:thumbnail) thumbnail = JSON.parse(thumbnail_json).symbolize_keys - ActiveRecord::Base.transaction do - user_avatar = UserAvatar.create!( - user: user_to_edit, - thumbnail_crop_x: thumbnail[:x], - thumbnail_crop_y: thumbnail[:y], - thumbnail_crop_w: thumbnail[:width], - thumbnail_crop_h: thumbnail[:height], - ) - - user_avatar.attach_image(upload_file) - end + user_avatar = UserAvatar.create!( + user: user_to_edit, + thumbnail_crop_x: thumbnail[:x], + thumbnail_crop_y: thumbnail[:y], + thumbnail_crop_w: thumbnail[:width], + thumbnail_crop_h: thumbnail[:height], + private_image: upload_file, + ) render json: { ok: user_avatar.valid? } end