Dynamic CSS generation doesn't work in Rails4

2019-09-22 07:01发布

The following code isn't working, I need to create css class like 'read-more-105','read-more-106' etc, according to tale.id's vale

<%= simple_format truncate(plot.description, length: char_counter){link_to "Read More",'', class: 'read-more-<% tale.id %>'} %>

1条回答
叼着烟拽天下
2楼-- · 2019-09-22 07:34

you need string interpolation here:

<%= simple_format truncate(plot.description, length: char_counter){link_to "Read More",'', class: "read-more-#{tale.id}" } %>

As you can not have <% %> inside a <% %> or <%= %>.

查看更多
登录 后发表回答