R
R
Ruslan Galiev2014-09-17 15:18:53
Ruby on Rails
Ruslan Galiev, 2014-09-17 15:18:53

Rails: how to properly separate the functionality of different user roles?

Hello
There are 4 user roles in the system (devise+cancan). Now the check for the role occurs in the controllers and in the views, but this was a temporary and definitely not the right decision. At the moment, you need to enter another user role. So I decided to redo the process. So far, I think the solution is checking for a role in application_contoller and assigning a specific namescape. Could you tell me if this option is not quite right for this situation and is there a better solution?
Update: Ideally, the address should not be affected by namescape at all. So that in the address bar for all user roles everything is the same. The question is how when to do so that, depending on the role of the user, a certain namespace is assigned (I don’t even know how to say it correctly).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Vsk, 2014-09-17
@viktorvsk

In what situation? When does validation happen in controllers and views? Then check somewhere in the models or lib folder.

F
FanKiLL, 2014-09-17
@FanKiLL

Why don't you like checking permissions in controllers and views?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question