Skip to content

Commit

Permalink
Hotfix again: Directly pass upload file to avatar creation
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorbg committed Oct 29, 2024
1 parent 5249ce8 commit e766043
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e766043

Please sign in to comment.