views:

44

answers:

2

We are using the devise gem for authentication in a Rails 3 application. We have multiple roles and from the devise stand-point, the roles will differ in terms of confirmation, activation and remember me functionality.

The devise documentation has examples of two scopes being defined. One is the User itself and the other one is the admin role.

Can I have something like this? I would create a User model. And then I would create 3 roles:

  • Role1
  • Role2
  • Admin

Does devise support this? Has anybody tried this out?

A: 

Devise is a authentication plugin and what you looking for is authorization solution. Those are quite different topics. Take a look for example on http://github.com/ryanb/cancan

mdrozdziel
A: 

CanCan is by far your best solution for roles with ruby, I'd suggest checking out Tony's Usage of Devise/CanCan to create a roles based system. It took me a little bit to get exactly how to work it out, but now it works wonders for me.

Tarellel