fix: declare the coder for the custom column - #22
Merged
Conversation
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:`.
danquinney
force-pushed
the
fix/serialize-coder
branch
from
August 30, 2026 12:22
59d43db to
80d31b3
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Apps that adopt
config.load_defaults 7.1getactive_record.default_column_serializer = nil, and from Rails 7.1serializethen insists on an explicit coder:Attach::Attachmentdeclaresserialize :custom, type: Hash, default: {}without one, and becauseAttach::Railtieloads the model during initialization the host app fails to boot. Found while moving Dial 9 Connect toload_defaults 7.1.Change
serialize :custom, coder: YAML, type: Hash, default: {}— same on-disk format as today (YAML), just declared explicitly. Active Record < 7.1 ignores the keyword, exactly as it already ignorestype:from 2.0.3, so the support floor is unchanged.Verification
Second commit fixes the test setup so the CI matrix can actually run again (nothing else changed):
MigrationContext.newonly takes the schema migration class before 7.1,loggeris required explicitly for Rails < 7.1 on concurrent-ruby ≥ 1.3.5, and the Rails 6 gemfile pinssqlite3 ~> 1.4(the 6.1 adapter's requirement, which 2.x broke on Ruby ≥ 3.0).Local runs of the matrix corners, all 40 examples, 0 failures:
rails6.gemfilerails7.gemfileAlso checked that booting the model with
ActiveRecord::Base.default_column_serializer = nil(whatload_defaults 7.1does) loads and reportsActiveRecord::Coders::YAMLColumnas thecustomcoder with this change, and raises the error above without it.