From d1225c30c529741d28bdd08acdc5d5f9d1ec4892 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 5 Sep 2025 16:28:24 -0700 Subject: [PATCH] Fix migration error: Use .all.group_by instead of .group_by on model class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Gemfile.lock | 6 ++++++ db/migrate/20250626212442_add_position_to_image_uploads.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a09825a0..d9ba876f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/db/migrate/20250626212442_add_position_to_image_uploads.rb b/db/migrate/20250626212442_add_position_to_image_uploads.rb index 8cc9643d..918ada6d 100644 --- a/db/migrate/20250626212442_add_position_to_image_uploads.rb +++ b/db/migrate/20250626212442_add_position_to_image_uploads.rb @@ -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)