除非用户有权查看,否则我想隐藏几个链接。我在我的User模型中创建了一个名为super的额外列,我想做类似于下面代码的事情:
<% if current_user.super == true %>
<li><%= link_to "Hidden", hidden_path %></li>
<% end %>
super被定义为布尔值并且已经设置为true。我收到一个错误,说他们不认识“超级”
答案 0 :(得分:1)
super
是一个ruby关键字。有了设计,你可以检查
<% if current_user.present? %>
<li><%= link_to "Hidden", hidden_path %></li>
<% end %>
或
<% if user_signed_in? %>
<li><%= link_to "Hidden", hidden_path %></li>
<% end %>
Devise提供了这些辅助方法,
https://github.com/plataformatec/devise#controller-filters-and-helpers