0

我越来越

$ syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('

在这一行

$ %li = link_to 'Features', features_path class => ('active' if params[:action] == 'features')%li
4

1 回答 1

2
%li = link_to 'Features', features_path, :class => ('active' if params[:action] == 'features')
  • 删除尾随%li.
  • 我还把类变成了一个符号,并在它前面加了一个逗号。

编辑:

要将类添加到%li标签中,请尝试以下操作:

%li{:class => (params[:action] == 'features' ? 'active' : nil)}
  = link_to 'Features', features_path
于 2012-06-24T04:36:14.063 回答