Description
In 0.8, it was possible to determine if the serializer should include a root element or not via the root
option, like so:
class MySerializer < ActiveModel::Serializer
self.root = (((true or false)))
end
This has been removed in 0.10, and setting self.config.adapter = :attributes
instead does nothing. Actually, it seems that the settings at the class level are ignored altogether.
By taking a look at https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/serializer/configuration.rb , one would expect that it should be possible to change the settings at the class level (there's even a comment that mentions it), but it doesn't seem to be possible. The options hash on classes deriving from ActiveModel::Serializer
is always empty ({}
), while I would have expected to see the default values in it. If I do something like:
class MyTestClass
include ActiveModel::Serializer::Configuration
end
then MyTestClass.config
has the expected values in it.
I can change the settings in an initializer, but that's global.
Would it be possible to change the root behavior at the class level again?