Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct Associations Ruby on Rails

Can someone help me to correct my associations ?

I have the following models:

User, Developer, Application, Comments, Rating, Permission

Requirements:

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. 

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?

like image 256
glarkou Avatar asked Jul 07 '11 22:07

glarkou


1 Answers

You are confusing models with authorization.

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.

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

like image 83
Msencenb Avatar answered Oct 03 '22 10:10

Msencenb