我有一个Contact模型的葡萄实体,它引用了User模型两次:
SELECT id,
group_id,
object_id,
object,
param,
(SELECT count(*)
FROM controlled_object AS co2
WHERE group_id = controlled_object.group_id)
FROM controlled_object;
当我得到一个提供联系的端点时,我有以下错误
class Contact < ApplicationRecord
belongs_to :user, foreign_key: :user_id
belongs_to :contact, class_name: 'User', foreign_key: :contact_id
def entity
Entity.new(self)
end
class Entity < Grape::Entity
expose :contact do
expose :id
expose :user, as: :inviter, merge: true, using: User::Entity
expose :contact, as: :invitee, merge: true, using: User::Entity
expose :status
end
end
end
如何使其包含联系人实体中的邀请者和被邀请者的用户实体?