I use Devise in my new project,but I have some problems in roles.
There are two kinds of user in my project,but these two kinds of user have deferent data structure(very different).
I Know Devise supports roles,but how should I deal with the deferent user data structure?
Thank you.
Devise documentation states that you can have as many Roles with different models as you want (configuring multiple models)
You just set up the other model as you did with the first one and then add to
routes.rbAnd then you can use inside your controllers and views:
The main question is how to let both of these accounts access the same controller (if it is applicable to your case), because of the two
before_filtersthe first would always redirect to login page, if that is not the logged-in role (say :admin). You would probably have to implement a custom before_filter to validate the session against two roles simultaneously.You could probably work around this with custom routes for these roles. E.g
/admin/projectsand/user/projects. In that case theauthenticatemethod could be helpful.