Devise role based routing
Posted
by
teknull
on Stack Overflow
See other posts from Stack Overflow
or by teknull
Published on 2012-06-15T14:57:25Z
Indexed on
2012/06/15
15:16 UTC
Read the original article
Hit count: 192
I have an app with multiple users. Each user as a theoretical role (user, client, etc). I've designed a view/controller for each user type.
I want to be able to login each type of user do a different root url and lock them to it.
Originally I was going to add a column to Users in Devise called role and so I can differentiate the users. The problem I'm having is how to say in routes.rb if current_user.role == "client" root :to => 'controller#index'
Once they are logged in to the page I also want to keep them from being able to visit any of my other paths ie: domain.com/calls domain.com/units
I've been looking into cancan to run alongside Devise but I'm not sure if this is the answer.
© Stack Overflow or respective owner