From 80d31b31fc4d622679a18b1e06b5e28ad40adbd0 Mon Sep 17 00:00:00 2001 From: Dan Quinney Date: Sun, 30 Aug 2026 13:21:10 +0100 Subject: [PATCH 1/2] fix: declare the coder for the custom column Applications on `config.load_defaults 7.1` run with `default_column_serializer = nil`, and Active Record then requires every `serialize` call to name its coder; Attach::Attachment failed to load with "missing keyword: :coder". Naming YAML keeps the existing storage format. Older Active Record versions ignore the keyword, as they already do for `type:`. --- lib/attach/attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/attach/attachment.rb b/lib/attach/attachment.rb index 9833506..0e93ab2 100644 --- a/lib/attach/attachment.rb +++ b/lib/attach/attachment.rb @@ -25,7 +25,7 @@ class Attachment < ActiveRecord::Base validates :digest, presence: true validates :token, presence: true, uniqueness: { case_sensitive: false } - serialize :custom, type: Hash, default: {} + serialize :custom, coder: YAML, type: Hash, default: {} before_validation :set_token before_validation :set_digest From 9eb8da33fc6feb3e697c291b1b93bbcf0d95580f Mon Sep 17 00:00:00 2001 From: Dan Quinney Date: Sun, 30 Aug 2026 13:27:14 +0100 Subject: [PATCH 2/2] test: run the suite on current Active Record and gem releases Three things had rotted under the CI matrix: MigrationContext.new no longer takes the schema migration class from 7.1 (and 6.1 still requires it), Rails < 7.1 needs logger required explicitly since concurrent-ruby 1.3.5, and the Rails 6 gemfile resolved sqlite3 2.x on Ruby >= 3.0 where the 6.1 adapter wants ~> 1.4. Verified on Ruby 2.7 and 3.2 with both gemfiles. Claude-Session: https://claude.ai/code/session_01QDRJWFWvDq5Nu6aWm4gY6t --- gemfiles/rails6.gemfile | 2 +- spec/spec_helper.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gemfiles/rails6.gemfile b/gemfiles/rails6.gemfile index 1d64213..81ddd94 100644 --- a/gemfiles/rails6.gemfile +++ b/gemfiles/rails6.gemfile @@ -12,5 +12,5 @@ group :test do gem 'factory_bot' gem 'rspec' gem 'shoulda-matchers' - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e0e6267..97d8b60 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'logger' require 'active_record' require 'shoulda-matchers' require 'factory_bot' @@ -10,8 +11,10 @@ ActiveRecord::Base.include Attach::ModelExtension ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' -ActiveRecord::MigrationContext.new(File.expand_path('../db/migrate', __dir__), - ActiveRecord::SchemaMigration).migrate(nil) +migration_context_args = [File.expand_path('../db/migrate', __dir__)] +# Active Record < 7.1 needs the schema migration class; 7.1+ takes it from the connection +migration_context_args << ActiveRecord::SchemaMigration if ActiveRecord.version < Gem::Version.new('7.1') +ActiveRecord::MigrationContext.new(*migration_context_args).migrate(nil) ActiveRecord::Migration.create_table :users do |t| t.string :name t.datetime :suspended_at