简体   繁体   English

Rails雷达/论坛论坛引擎-控制对某些论坛或主题的访问

[英]Rails radar/forem forum engine - controlling access to certain forums or topics

I'm using forem as forum engine and have it attached to my User model. 我正在使用Forem作为论坛引擎,并将其附加到我的用户模型上。

As part of my User model, I have "experts" and "novices" as the two different types of users. 作为我的用户模型的一部分,我拥有“专家”和“新手”作为两种不同类型的用户。

If I only want to show the "expert" forum to "expert" users, what is the best way to control this access within forem? 如果我只想向“专家”用户显示“专家”论坛,那么在外汇交易中控制此访问权限的最佳方法是什么?

You could try to modify the view under app/views/forem/forums/_forum.html.erb , enclosing all with this: 您可以尝试在app/views/forem/forums/_forum.html.erb下修改视图,并用以下内容将其app/views/forem/forums/_forum.html.erb起来:

<% if forem_user.expert? %>
  ...
<% end %>

Note: if you don't have the forem views, you have to generate them with rails g forem:views . 注意:如果没有forem视图,则必须使用rails g forem:views生成它们。

Cheers! 干杯!

EDIT: 编辑:

The last version of Forem allows to redefine methods for permissions in your User model. Forem的最新版本允许重新定义用户模型中权限的方法。

https://github.com/radar/forem/wiki/Authorization-System https://github.com/radar/forem/wiki/Authorization-System

So, in your case, you'd define the method can_read_forem_forum?(forum) and return true if the user is expert. 因此,就您而言,您将定义can_read_forem_forum?(forum) ,如果用户是专家,则返回true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM