Closed
Conversation
Fixes #1479 Rails 8.1 changed `ActionDispatch::Routing::Mapper::Resources::Resource#initialize` to require keyword args (only:, except:, **options). The JSONAPI‑Resources DSL still passes a positional options hash, so jsonapi_relationships never runs and relationship routes are missing. Adding the ** operator to `**options` converts the hash into keyword args. Tests that fail without this change: `test/controllers/controller_test.rb` I ran into several other deprecations. * `ActiveSupport::Deprecation.silenced` will not work the way it was set up in the tests because `#silenced` now works on an instance of `Deprecators` instead of globally. I created a module `JSONAPI.deprecator` so that the gem can use its own instance of Deprecator and the tests can work as designed. * `:unprocessable_entity` was deprecated in favor of `:unprocessable_content` * Used lazy method evaluation for `Configuration` because Rails 8.1 does not guarantee class-body initialization order, so @configuration was returning `nil`. * My team uses an active_record oracle adapter. Oracle unquoted identifiers are automatically stored as UPPERCASE. Rails 8.1 no longer normalizes the case automatically for queries, so I added a condition for using the oracle adapter. * `length` is no longer a valid column constraint. Used `limit` instead * `references:` is not a valid option key for ActiveRecord migrations. Excplicitly pass a foreign_key to the things table instead. * `:none` is not a valid active_record schema format in Rails 8.1 * Disabled foreign key constraints for SQLite tests * Use `ActiveRecord::Base.connection.quoted_true` as it is database agnostic There are a few warnings in the test suite that I did not address because they were unrelated to this change.
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.
Fixes #1479
Rails 8.1 changed
ActionDispatch::Routing::Mapper::Resources::Resource#initializeto require keyword args (only:, except:, **options). The JSONAPI‑Resources DSL still passes a positional options hash, so jsonapi_relationships never runs and relationship routes are missing.Adding the ** operator to
**optionsconverts the hash into keyword args.Tests that fail without this change:
test/controllers/controller_test.rbI ran into several other deprecations.
ActiveSupport::Deprecation.silencedwill not work the way it was set up in the tests because#silencednow works on an instance ofDeprecatorsinstead of globally. I created a moduleJSONAPI.deprecatorso that the gem can use its own instance of Deprecator and the tests can work as designed.:unprocessable_entitywas deprecated in favor of:unprocessable_contentConfigurationbecause Rails 8.1 does not guarantee class-body initialization order, so@configurationwas returningnil.lengthis no longer a valid column constraint. Usedlimitinsteadreferences:is not a valid option key for ActiveRecord migrations. Excplicitly pass a foreign_key to the things table instead.:noneis not a valid active_record schema format in Rails 8.1ActiveRecord::Base.connection.quoted_trueas it is database agnosticThere are a few warnings in the test suite that I did not address because they were unrelated to this change.
All Submissions:
### New Feature Submissions:- [ ] I've submitted an issue that describes this feature, and received the go ahead from the maintainers.- [ ] My submission includes new tests.- [ ] My submission maintains compliance with JSON:API.Bug fixes and Changes to Core Features:
Reviewer Checklist: