active_model_serializers icon indicating copy to clipboard operation
active_model_serializers copied to clipboard

How to get the attribute key from the serializer ?

Open bsylvain opened this issue 6 years ago • 0 comments

I want to fix this issue : https://github.com/rails-api/active_model_serializers/issues/2250

To do so I need to ask to the serializer if an attribute has a key in the default serializer. From what I understand It should be done in https://github.com/rails-api/active_model_serializers/blob/0-10-stable/lib/active_model_serializers/adapter/json_api/error.rb

In the self.resource_errors method, it is possible to retrieve the default serializer with : ActiveModel::Serializer.serializer_for error_serializer.object

But I cannot manage to get the json Key for an attribute ou of the serializer. How can I do that ?

bsylvain avatar Nov 15 '19 15:11 bsylvain