Reputation: 892
<%= d.box, :class => "something" %>
What is my syntax error here? Can't figure it out. Class is not properly adding to erb variable.
Error message:
syntax error, unexpected =>, expecting :: or '[' or '.' ...pend=( d.box, :class => "something" );@output_buffer.safe... ... ^
Upvotes: 1
Views: 2245
Reputation: 1602
<%= %>
means just run code and print on view.
so, <%= d.box, :class => "something" %>
raise error.
I think you tried call helper method.
Show document about TagHelper
Upvotes: 0
Reputation: 1545
You can't add class to a simple value (d.box
). ERB will render the value of d.box
, let's say 123. So you are trying to add class to 123
which is not a html element. You should add class name to the parent html element.
Upvotes: 3