Reputation: 979
I'm displaying a link as a string in erb:
<%= link_to (@teacher.id + 1).to_s, "#" %>
How can I add one space at the beginning?
If I do this: " " + (@teacher.id + 1).to_s
, the space is ignored, and if I do this: " " + (@teacher.id + 1).to_s
or this: ' ' + (@teacher.id + 1).to_s
, it just interprets " " as a five-character string.
Upvotes: 2
Views: 1878
Reputation: 10796
Try this:
<%= link_to " #{@teacher.id + 1}".html_safe, "#" %>
Reference: http://apidock.com/rails/String/html_safe
Upvotes: 8