R
R
Ruslan Galiev2014-02-25 08:31:51
Ruby on Rails
Ruslan Galiev, 2014-02-25 08:31:51

Rails: how to correctly separate views (view) of different user roles?

Hello
There are 4 user roles in the system (devise+cancan). Now the check for the role occurs in the entity 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 redirecting to a specific namescape. Could you tell me if this option is not quite right for this situation and is there a better solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
@
@mgyk, 2014-02-25
_

We used https://github.com/inossidabile/protector and danced in the views from the visibility of attributes, which gives sufficient convenience, since without changing the views you can change the logic of the roles and introduce new ones

A
Alexey, 2014-02-26
@fuCtor

It may help to define your own resolver for templates, which will use the role as an additional parameter, then it will be possible to split the views into separate files.
For example, as done here:
blog.plataformatec.com.br/2011/04/default-views-in...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question