Nick van der Wildt


580 Experience
5 Lessons Completed
0 Questions Solved


Posted in Setup for roles and authorization

Hi Jacob,

Just letting you know that I've figured it out! Turns out I didn't need Rolify at all. I've made a table called Project_users that has a has_many through relationship with Users and Projects. On the Project_users table, there's a role column for owner, editor and contributor. It works beautifully.

Thanks for pushing me in the right direction!

Posted in Setup for roles and authorization

Thanks Jacob! Very much appreciated. I think you're right and I should 'play' more in order to find out what works best for me.

Out of curiosity, would you recon ProjectMembership is a better name for the table than Roles? Is this a certain convention that Rails developers would prefer?

Thanks for your swift responses!


Posted in Setup for roles and authorization

Hi Jacob,

Thank you so much for your reply!!

Would you say that a ProjectMembership table is all I need, or does Rolify add any features that I might need later on? I'm kind of confused as to whether I need/could really use a gem or if adding a table would be sufficient.

I do think that I now understand the difference between Rolify and Cancancan. Based off of Chris his tutorial on this, it does seem like Cancancan has a way to define roles for users. This makes it seem to me that Rolify is not necessary anymore?

Sorry for another question 😁

Posted in Setup for roles and authorization

Hi all!

This is my first question for the community. I'm super excited to be here and hope to be answering a few of them myself as well.

I'm working on a rails project where people can work on a project together - books to be specific. I have a need for the following roles:

  1. An admin/support role, someone from customer support who can dive into any project and help managing a project whenever they're contacted with a question
  2. An editor, someone who has rights to manage the content in the book and who can invite/manage people who can contribute to the project
  3. A contributor, someone who can add content to the book, but who doesn't have the ability to see what others contribute, nor manage any of the contributors. They're simply asked for input and that's it.

I have a model called User set up with Devise.

My challenge is that both editors and contributors can have multiple projects: an editor could be an editor for project A, but a contributor for project B and C. A contributor could likewise be a contributor for project A and an editor for project B and C. A user can't be both an editor and a contributor for one project. (However, I can imagine the requirement popping up that my client wants an admin to be able to 'view as editor' or 'view as contributor.' - but that's for later concern)

I had previously set up an enum role column on the User table, but this doesn't take into account the fact that a user can have different roles for different projects. I'm looking into creating a different roles table, but I wonder what my best options are.

My research has led me to Cancancan and Rolify together, but I fail to understand the difference between them and whether I could also just use either of them. In the tutorial from Chris, I also understand that Cancancan has a role functionality. Would I really need Rolify then?

I'd really appreciate any advice in the right direction! I've been wandering the internet for a while now, haha.


logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.