正确关联的Ruby on Rails [英] Correct Associations Ruby on Rails

查看:95
本文介绍了正确关联的Ruby on Rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我纠正我的联想?

Can someone help me to correct my associations ?

我有以下型号:

User, Developer, Application, Comments, Rating, Permission

要求:

A user can be a Developer or not.
A user can have Default Permissions and Permissions for each application
A user can install multiple Applications
A user can comment and rate multiple Applications
A developer can develop multiple applications
An application can request a list of permissions. 

我已经创造了一些社团,但我相信它不是100%正确,或一个简单的方法来做到这一点存在。

I already created some associations but I believe its not 100% correct or an easier way to do it exist.

有人建议我做一个正确的方法是什么?

Can someone suggest me a correct way to do it?

推荐答案

您是混乱的模型授权。

您应该检查出金灿灿的基于角色的授权。例如,你不需要你的开发模式,因为它只是一个不同的角色/权限的用户。

You should check out CanCan for role based authorization. For example you don't need your developer model since its just a user with a different role/permissions.

编辑:改变基于角色的身份验证到基于角色的授权。作为注释下面指出的认证和授权的区别。

Changed 'role based authentication' to 'role based authorization'. As the comment below points out the difference between authentication and authorization.

这篇关于正确关联的Ruby on Rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆