Search code examples
ruby-on-railsruby-on-rails-4cancancanrolify

How to handle if one of user's role (say teacher) have many other roles in rolify and cancancan gem?


I'm making a rails app in which one of user's have a teacher role and a teacher can teach many classes also a class can have many teachers. So how can i handle this in rolify and cancancan gem? I'm using rolify and cancancan gem for user roles.


Solution

  • I think a better solution would be to use a many to many relationship between teachers and classes. Using rolify helps you define multiple user roles and cancancan helps you define access permissions to these roles.