scinote-web/app/serializers/user_serializer.rb

18 lines
369 B
Ruby
Raw Normal View History

2023-12-05 03:59:16 +08:00
# frozen_string_literal: true
class UserSerializer < ActiveModel::Serializer
include Canaid::Helpers::PermissionsHelper
include Rails.application.routes.url_helpers
attributes :id, :name, :avatar_url
attribute :current_user
2023-12-05 03:59:16 +08:00
def avatar_url
avatar_path(object, :icon_small)
end
def current_user
instance_options[:user].id == object.id
end
2023-12-05 03:59:16 +08:00
end