We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
class ThirdPartySerializer < ActiveModel::Serializer attributes :session_id, :token, :started_at def token additional_data = { role: current_user.role, userId: current_user.id }.to_json THIRD_PARTY.generate_token(object.session_id, data: additional_data) end end
In this context, the current_user is undefined.
current_user
Add a private get current user to the serializer.
private
class ThirdPartySerializer < ActiveModel::Serializer #....(existing code) private def current_user_fallback @current_user_fallback ||= @instance_options[:current_user] || current_user end end
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problem:
In this context, the
current_user
is undefined.Solution:
Add a
private
get current user to the serializer.Lesson:
The text was updated successfully, but these errors were encountered: