[WIP] Allow users to opt-out from the ActionController extensions#1636
Open
bf4 wants to merge 1 commit intorails-api:masterfrom
Open
[WIP] Allow users to opt-out from the ActionController extensions#1636bf4 wants to merge 1 commit intorails-api:masterfrom
bf4 wants to merge 1 commit intorails-api:masterfrom
Conversation
Member
Author
|
I marked this as WIP since I'd like to think over the implementation a bit and this also needs tests. |
Contributor
|
I like the idea of setting the option in the rails config. |
| class << self | ||
| attr_accessor :enabled | ||
| end | ||
| self.enabled = true |
Member
Author
There was a problem hiding this comment.
(pardon the awful pseudo code)
I was actually just thinking about having
- a configurable default 'ams_ify_controller = true`
- and then in the controller, by default we only mix in a 'shim' module that
- has config methods, e.g. ams_ify_controller
- so that by default ActionController::Serialization would be included in action controller
- but if the default were set to false, then individual controllers would need to opt in by setting
ams_ify_controller true. - the method would just extend the controller with ActionController::Serialization when true
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.
Purpose
ActionController::Serializationinto the controllerChanges
Add
ActionController::Serialization.enabled = falseto an initializer and it won't be mixed in.Caveats
This doesn't exactly solve #1500 since it doesn't include any AMS code in the controller, and passing
serializeroreach_serializerwon't workPerhaps config should come from Rails, rather than be set on the mixin. e.g.
Rails.configuration.action_controller.render_json_with_active_model_serializers = falseRelated GitHub issues
serializer_lookup_enabledin controller doesn't retain Adapter for entire render #1500And many more
Additional helpful information
cc @trek