At the moment, I have three Models:
Users, Applications, Permissions
Every User has some Default Permissions:
eg: Saving something to Disk
Deleting something from Disk
etc (all permissions are booleans)
Every Application Requires A list of permissions. If those permissions are not set TRUE for Default permissions the Application requests those permissions.
So from this:
In Permission.rb I have:
belongs_to :user
belongs_to :application
Is it better to spit the Permission Model to 2 parts (App_Permissions, Default_Permissions) or do you suggest something more clever (Because the saved Object for Default Permissions will have a nul value of application_id)?
Thanks
I won’t use any model if it’s just meant to store booleans.
You could add has many boolean values in a single column of your table, see screencast.
When it comes to default values, I have two approaches:
adding default values in migrations
creating a constant and initializing objects with it’s values
I prefer the second option but I’d not use a
Defaultmodel unless it has to be changed dynamically by the site admins.