全部,尝试在 erb 文件中分配类时出现以下语法错误:
SyntaxError in Posts#index
Showing [..]/app/views/posts/_post.html.erb where line #5 raised:
[..]/app/views/posts/_post.html.erb:5: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.'
...append= ( post.title, :class => 'my-custom-class' );@output_...
...
^
3: <td>
4: <div>
5: <%= post.title, :class => 'my-custom-class' %>
6: </div>
7: </td>
我可以将类添加到<div>
- 即<div class='my-custom-class'> .. </div>
,但是没有更优雅的方式,没有 div,将类分配嵌入到 erb 子句中?
想法在这里?