How to create multiple roles for single user in ruby on rails?

Raj

I am trying to create a web application using ruby on rails. In this application a user has multiple roles like

  1. role1 = teacher
  2. role2 = student
  3. role3 = staff

But the thing is a user can switch between these roles by changing account settings in the application.

eg : Student can also change his role as teacher and then they can teach someothers

When they change the role the pages, timeline, homepage everything should be display according to their current role.

How can i model the database for this and how can i perform the associations for this ?

I am new to ruby on rails so please help & thanks in advance!

Rajaraman

Ofcourse! you can keep track of current user and then you assign user role when they switch.

Perfect illustration for this scenario

If not you can also use rolify gem to add or remove roles and [cancan][3] gem for authorization.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

User Roles in Ruby on Rails

How to assign Multiple roles to a single user in wordpress

How to create multiple links from a single array of strings Rails - Ruby

How to create XACML policy and request single user having multiple roles in same resources or different resources

Ruby on rails Updating User roles

How to handle different roles for multiple elements for a single user?

Is it possible to create a MongoDb user with multiple roles in Java?

How to create a user/event tracking tool, backed by Ruby on Rails

Rails Associations - Multiple users fulfilling different roles for single model

Can a single Gherkin scenario have multiple user roles?

how to Assign Multiple Roles for a user in wordpress?

Ruby on rails create a single validation and use it everywhere

Ruby on Rails update multiple records in a single query

Multiple User Roles in Authorize

Ruby on rails "Could find user with id= create"

Ruby on Rails: I cannot create a new user

How do create large number of rows with a single sql statement in ruby on rails

Rails 4 user roles and permissions

How to create a form to edit user roles with FriendsOfSymfony UserBundle

How to create user/roles relation in UML class diagram?

How to Assign a Gateway Fee in WooCommerce to Multiple User Roles?

how to add multiple roles to an admin user in Apache tomcat 8?

how to add multiple roles to an admin user in Apache tomcat 8?

How to implement multiple user types with different roles and permissions in Django?

How to structure a .NET Core MVC project for multiple user roles?

Rails create multiple records based on user input

Create sample data on devise user create in Ruby on Rails

Firebase :: Create first user with roles

How to specify user roles