Mike Litt
Mike Litt

Reputation: 65

Syntax error, unexpected keyword_class, expecting keyword_do or '{' or '('

I'm getting

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

in this line

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

Upvotes: 0

Views: 1402

Answers (1)

stephenmurdoch
stephenmurdoch

Reputation: 34613

%li = link_to 'Features', features_path, :class => ('active' if params[:action] == 'features')
  • Remove the trailing %li.
  • I also turned class into a symbol and prepended it with a comma.

Edit:

To add the class to the %li tag, try this:

%li{:class => (params[:action] == 'features' ? 'active' : nil)}
  = link_to 'Features', features_path

Upvotes: 2

Related Questions