Add to serializer only for staff and current user

This seem to be the droids i was looking for :slight_smile:

  add_to_serializer(:post, :user_xxx, false) {
    #object.user.custom_fields['xxx'] if object.user && scope.is_admin?
    #object.user.custom_fields['xxx'] if object.user && scope.is_moderator?

    # Staff will allow for Admins and Moderators
    object.user.custom_fields['xxx'] if object.user && scope.is_staff?
  }
3 Likes