如何分配不同类型的角色(代理和客户端)

问题描述 投票:1回答:1

我正在使用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

如何建立以上关联。请帮我。谢谢

ruby ruby-on-rails-5
1个回答
0
投票

我通过以下关联解决了上述问题。让我知道我是否错了

© www.soinside.com 2019 - 2024. All rights reserved.