lundi 6 août 2018

Ruby on Rails 5. Mongoid. Is it an antipattern for a model to make outbound calls to other controllers?

I have a schema in which users own systems and have roles. Roles in turn have privileges associated with them. If I want to access the roles or privileges of a specific user, where should I put the appropriate logic? For example, one of the privileges is 'SystemAdministrator'. From 10,000 metres it looks like a #is_sysadmin? method in the User model would work -- but it would have to makes requests through the Roles and Privileges controllers to find an answer, and that doesn't sound like something a model should be doing.

Is it permissible and a valid pattern for a model to make outbound calls to controllers of other models?

Thanks!

Aucun commentaire:

Enregistrer un commentaire