Description
When serializing a resource, the serializer class name needs to be "#{resource.class.name}Serializer"
. There is no way to influence this behavior, neither globally or per resource.
Before the rewrite resources could implement active_model_serializer
, which when implemented returns the serializer class to be used.
For a single resource it is possible to manually invoke a specific serializer, but for collections or associations there is no way to influence the serializer lookup.
It would be great if this policy was configurable, for instance by setting an object in the configuration that responds to serializer_for(resource)
, or even better, call
, i.e.
ActiveModel::Serializer.setup do |config|
config.serializer_lookup = ->(resource) do
::Api::Serializers.const_get("#{resource.class.name}Serializer")
end
end
Alternatively bringing the old behavior back would be great as well.
I'm happy to provide a PR but would like to hear the opinion of the maintainers.