SyntaxError - 语法错误,意外':'类:

时间:2014-09-23 14:53:05

标签: ruby-on-rails ruby erb

我收到以下语法错误:

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]

1 个答案:

答案 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' : '' }" %>