Skip to content
Discussion options

You must be logged in to vote

You can use params where you can pass user object.
You can also use inheritance since it's just Ruby!

# DO NOT TOUCH THIS CLASS!
class ContactLiteSerializer
  include Alba::Serializer

  attributes :id, :name
end

class ContactFullSerializer < ContactLiteSerializer
  attributes :birthday, :home_address, if: proc { |contact| params[:user].has_permission?(contact) }
end

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ramaboo
Comment options

@okuramasafumi
Comment options

Answer selected by okuramasafumi
@okuramasafumi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants