Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个声纳插件,需要根据用户角色(即管理员)在我的小部件( html.erb )中显示某些元素。
检查当前用户权限的推荐方法是什么?
我没有检查这些是否可以在插件中访问,但您可以尝试使用is_admin?或has_role?(:admin)
is_admin?
has_role?(:admin)
请参阅下面的链接以了解使用情况,
https://github.com/SonarSource/sonarqube/blob/master/server/sonar-web/src/main/webapp/WEB-INF/app/views/components/index.html.erb
https://github.com/SonarSource/sonarqube/blob/master/server/sonar-web/src/main/webapp/WEB-INF/app/views/issues/manage.html.erb