panko_serializer
panko_serializer copied to clipboard
Rendering serializers with additional parameters
AMS has facility to pass additional parameters to serializer i.e, render json: user, include_token: true, current_user_id: user.id
It would be nice if we have similar feature to add additional parameters on Panko for both single object serializer and array serializers,
render json: Panko::UserSerializer.new.serialize_to_json(user) render json: Panko::ArraySerializer.new(users, each_serializer: Panko::UserSerializer)
Currently it just accepts 1 parameters to be passed on
Tried using, render json: Panko::Response.new( current_user_id: user.id, include_token: true, user: Panko::UserSerializer.new.serialize_to_json(user) )
But it's returning null response, and doesn't seem to be working.
[active_model_serializers] Rendered ActiveModel::Serializer::Null with Panko::Response.
@railsfactory-selva According to documentation you can pass hash of data with context
parameter.
https://yosiat.github.io/panko_serializer/attributes.html#method-attributes
@railsfactory-selva is @irondnb answers your question?