문제

In my rails 4 erb view i have this link,

<%= link_to "Download @served_file.title", "/public/uploads/@served_file.file", :class => "btn" %>

However, it won't replace @served_object.title and @served_object.file with the text but just placing those lines inside a <%= %> works as expected.

도움이 되었습니까?

해결책

You need to interpolate the values into the string.

<%= link_to "Download #{@served_file.title}", "/uploads/#{@served_file.file}", :class => "btn" %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top