class SerializableAccount < JSONAPI::Serializable::Resource type "account" attributes :name attribute :users do @object.users.map do |user| if user.avatar.attached? avatar = Rails.application.routes.url_helpers.rails_blob_url(user.avatar, host: AppHost.new.domain_with_port) else avatar = nil end { email: user.email, name: user.full_name, role: user.account_auths.map(&:role).compact.join(", "), avatar: avatar } end end end