我正在为部分视图编写一些 Rails 代码,并且我希望它仅在有人已经登录到此处的站点时才显示评论字段。
如果页面被还不是站点成员的人查看,则shared/comment_not_logged_in
应该传入片段。
但是,我完全不知道为什么我不能运行相同的检查来决定页面是否应该在此处将类属性“missing_your_voice”添加到封闭的 div 元素中:
<li class="user_submission_form bubble comment_form <% "missing_your_voice" if not current_user %>">
<% if current_user %>
<%= image_tag(current_user.avatar(:comment), :class => "profile_pic") %>
<% form_for [parent, Comment.new] do |f| %>
<%= render "comments/form", :f => f %>
<% end %>
<% else %>
<%= render :partial => 'shared/comment_not_logged_in' %>
<% end %>
</li>
同样的成语,"missing_your_voice" if not current_user
在 irb 中返回字符串,也在控制台调试器中返回。
我在这里做错了什么?