动态CSS生成在Rails4中不起作用

时间:2014-10-28 09:21:18

标签: css ruby ruby-on-rails-4

以下代码不起作用,我需要创建css类,如'read-more-105','read-more-106'等,根据tale.id的代码

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

1 个答案:

答案 0 :(得分:2)

你需要字符串插值:

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

由于您在<% %><% %>内无法<%= %>