active_model_serializers: Meta key not being picked up !!
Custom meta not showing up even with root on active_model_serializers (0.9.3).
render :json => @place, :serializer => PlaceSerializer, :meta => {:content => "10", :type => "success"}
is working fine and meta is retrieved, however with:
render :json => @place, :serializer => PlaceSerializer, :meta => {:content => "10", :type => "success"}, :meta_key => 'message'
it’s not giving any meta or message.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (2 by maintainers)
Ah, I see that now @NeoElit. Is there a reason you don’t want to use meta for the details and status just for the http status code? I have a work around for this, but it involved making the whole return object separately, not in the render statement.
First I serialize the data by doing either:
serialized_data = ActiveModel::ArraySerializer.new(data, each_serializer: serializer_name, root: false)
orserialized_data = serializer_name.new(data, root: false)
And then I construct the response object:
and then I send it back:
render json: response, status: code