Fix migration error: Use .all.group_by instead of .group_by on model class

The AddPositionToImageUploads migration was calling group_by directly on the ImageUpload class instead of on a collection. This fixes the NoMethodError by properly calling ImageUpload.all.group_by.

Also updates Gemfile.lock with arm64-darwin platform support after bundle install.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andrew Brown 2025-09-05 16:28:24 -07:00
parent 3607e1f370
commit d1225c30c5
2 changed files with 7 additions and 1 deletions

View File

@ -1886,6 +1886,7 @@ GEM
faye-websocket (0.11.3)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.17.2-arm64-darwin)
ffi (1.17.2-x86_64-linux-gnu)
ffi-compiler (1.3.2)
ffi (>= 1.15.5)
@ -1964,6 +1965,7 @@ GEM
letter_opener (~> 1.9)
railties (>= 6.1)
rexml
libv8-node (16.19.0.1-arm64-darwin)
libv8-node (16.19.0.1-x86_64-linux)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
@ -2019,6 +2021,8 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.7.4)
nokogiri (1.18.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.8-x86_64-linux-gnu)
racc (~> 1.4)
observer (0.1.2)
@ -2213,6 +2217,7 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86_64-linux)
stackprof (0.2.27)
statsd-ruby (1.5.0)
@ -2273,6 +2278,7 @@ GEM
zeitwerk (2.7.2)
PLATFORMS
arm64-darwin-24
x86_64-linux
DEPENDENCIES

View File

@ -23,7 +23,7 @@ class AddPositionToImageUploads < ActiveRecord::Migration[6.1]
else
# Database-agnostic approach using Ruby
say_with_time("Backfilling positions for ImageUploads") do
ImageUpload.group_by { |img| [img.content_type, img.content_id] }.each do |group_key, images|
ImageUpload.all.group_by { |img| [img.content_type, img.content_id] }.each do |group_key, images|
ordered_images = images.sort_by { |img| [img.created_at || Time.current, img.id] }
ordered_images.each_with_index do |img, idx|
img.update_column(:position, idx + 1)