0

I am using rails and MongoId. I have 3 models - User, Project and Role. I want to manage user roles based on projects. For example: user1 has assigned to 2 projects, for project1 user1 may be admin, for project2 user1 may be a Quality Analyst.

How I can achieve this when using mongoid in rails.

Thanks in Advance.

piet.t
  • 11,718
  • 21
  • 43
  • 52
krishna m
  • 73
  • 1
  • 7

1 Answers1

1

You can use rolify and add multiple roles to user and in Project model filter if a user has a specified role and manage it.

uday
  • 1,421
  • 10
  • 19
  • Hi Uday, thanks for your solution, just now I went through it, looks easy and simple. My question is, will this work for mongoid? I am not using Active Record, I am using mongoid. – krishna m Feb 12 '19 at 06:52
  • yeah! there is documentation for `mongoid` too check it out. – uday Feb 12 '19 at 06:53
  • Thanks a lot Uday, Rolify suits perfectly for my requirement. – krishna m Feb 12 '19 at 07:23