在我的rails 4 erb视图中,我有这个链接,
<%= link_to "Download @served_file.title", "/public/uploads/@served_file.file", :class => "btn" %>
但是,它不会将@served_object.title
和@served_object.file
替换为文本,而只是将这些行放在<%= %>
中按预期工作。
答案 0 :(得分:2)
您需要将值插入到字符串中。
<%= link_to "Download #{@served_file.title}", "/uploads/#{@served_file.file}", :class => "btn" %>