我正在
$ syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('
在这一行
$ %li = link_to 'Features', features_path class => ('active' if params[:action] == 'features')%li
答案 0 :(得分: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