语法错误,意外=>,期待keyword_end haml_temp

时间:2015-08-17 17:06:58

标签: ruby-on-rails

我正在尝试将class属性应用于link_to块。在此SO帖子之后:Adding a class to link_to block

我写道:

 =link_to(who_we_are_path), :class => 'top-nav-anchor' do
        WHO WE ARE
        .glyphicon.glyphicon-plus

但是我收到以下错误:

al/app/views/shared/_top_nav.html.haml:110: syntax error, unexpected =>, expecting keyword_end haml_temp = link_to(who_we_are_path), :class => 'top-nav-anchor' do 

我使用新语法得到了同样的错误:

 =link_to(who_we_are_path), class:'top-nav-anchor' do
        WHO WE ARE
        .glyphicon.glyphicon-plus

1 个答案:

答案 0 :(得分:1)

删除路径周围的括号......

 =link_to who_we_are_path, class:'top-nav-anchor' do
    WHO WE ARE
    .glyphicon.glyphicon-plus