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: