I am working on a Ruby on rails project.
There are 5 Tables such as user table; role table; permission table; user_permission table; and role_user table.
Using a Current User ID,
Here Super Admin should able to create roles and permissions dynamically, i tried using cancan gem but getting error and not working properly,Is there any other solution for this, or can we create it without using any gems?
Kindly tell me any suggestion as i am a beginner
These are the model
User model
has_many :role_users has_many :roles, through: :role_users
validates :email,:presence => true
RoleUser model
belongs_to :user
belongs_to :role
Role model
has_many :role_permissions has_many :role_users has_many :users, through: :role_users has_many :permissions, through: :role_permissions
validates :name, presence: true
RolePermission model
belongs_to :permission belongs_to :role
Permission Model
has_many :permission_actions has_many :role_permissions has_many :roles, through: :role_permissions validates :subject_class, presence: true validates :action, presence: true
Aucun commentaire:
Enregistrer un commentaire