我正在使用devise作为具有角色角色的用户模型
用户具有一个称为“客户端”的角色
用户具有一个称为“代理”的角色
我想建立这样的关联
class User < ApplicationRecord
rolify
has_many :agents # if user role is client will get all agents
has_many :clients # if user role is agent will get all clients
end
如何建立以上关联。请帮我。谢谢
我通过以下关联解决了上述问题。让我知道我是否错了