Rails STI for User 模型,具有关联和身份验证
我正在开发一个网站,医生可以在其中管理患者、预约等。 一名医生可以有多名助手来帮助他们完成这些活动,并且一名助手可以属于多名医生。
医生和助理都应该能够从同一个登录表单登录,但由于显而易见的原因,他们根据自己的角色拥有不同的权限和关联,例如患者与医生相关联,而不是与助理相关联。
您建议如何解决这个问题的最佳方法?我正在考虑将 CanCan 用于授权部分,也许将 STI 用于用户模型,医生和助理可以从该模型继承身份验证部分,但是 STI 可以处理这两者之间的 HABTM 以及每个模型可能具有的其他关联吗?
预先非常感谢
I am developing a site where doctors can manage their patients, appointments, etc.
A doctor can have multiple assistants which help them with these activities, and an assistant can belong to multiple doctors.
Both doctors and assistants should be able to sign in from the same login form but for obvious reasons they have different permissions and associations depending on their role, for example patients are associated to the doctors, not to the assistant.
How you suggest would be the best way to approach this? I am contemplating CanCan for the authorization part, and maybe STI for a User model which Doctor and Assistant can inherit from for the authentication part, but can STI handle the HABTM between these 2, plus the other associations each model might have?
Thanks a lot in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以解决问题。
只需确保使用“类型”来设置用户是谁。然后,您可以使用以下内容:
确定对区域的访问权限。
如果您需要更多信息,请大声喊叫。
This should do the trick.
Just make sure you use 'type' to set which the user is. You can then use things like:
To determine access to areas.
Shout if you need more info.