我收到以下语法错误:
SyntaxError - syntax error, unexpected ':'
class: "glyphicon glyphicon-chevron...
^:
这是我的代码。我不确定发生了什么......
% if policy(Vote.new).create? %>
<div class="vote-arrows pull-left">
<div>
<%= link_to " ",
post_up_vote_path(post);
class: "glyphicon glyphicon-chevron-up #{(current_user.voted(post) && current_user.voted(post).up_vote?) ? 'voted' : '' }" %>
</div>
<div>
<strong><%= post.points %></strong>
</div>
<div>
<%= link_to " ",
post_down_vote_path(post),
class: "glyphicon glyphicon-chevron-down #{(current_user.voted(post) && current_user.voted(post).down_vote?) ? 'voted' : '' }" %>
</div>
</div>
<% end %>
这是我的红宝石版本:ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
答案 0 :(得分:2)
您的link_to
电话中间有一个虚假的分号:
<%= link_to " ",
post_up_vote_path(post); # <=== wat
class: "glyphicon glyphicon-chevron-up #{(current_user.voted(post) && current_user.voted(post).up_vote?) ? 'voted' : '' }" %>