Closed csaurav closed 6 years ago
In your render call, you can specify an expose
parameter, which allows you to expose arbitrary variables to serializable classes.
Example:
roles = { lucas: :admin }
render jsonapi: users, expose: { roles: roles }
Then you can refer to exposed parameters as instance variables in the serializable classes: e.g. @roles
.
Hi,
I have to show some attribute, based on the user role and for this matter, I have to pass current_user object to the SerializableMyClass.
How to do it ?
Thanks