Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering serializers with additional parameters #57

Open
railsfactory-selva opened this issue Sep 18, 2019 · 2 comments
Open

Rendering serializers with additional parameters #57

railsfactory-selva opened this issue Sep 18, 2019 · 2 comments
Assignees

Comments

@railsfactory-selva
Copy link

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.

@irondnb
Copy link

irondnb commented Dec 20, 2019

@railsfactory-selva According to documentation you can pass hash of data with context parameter.
https://yosiat.github.io/panko_serializer/attributes.html#method-attributes

@yosiat
Copy link
Owner

yosiat commented Jan 11, 2020

@railsfactory-selva is @irondnb answers your question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants