I have
<%=link_to distance_of_time_in_words_to_now(post.created_at), post %> ago
However I want to make 'ag开发者_运维知识库o' show up in link as well. Now its something like '20 minutes ago,' which kind of looks ugly. I want it to look like 20 minutes ago.'
I tried using #{} with no success and Google search turns out very little, especially since I don't even know what I'm looking for.
Any suggestions?
This must work:
<%= link_to "#{distance_of_time_in_words_to_now(post.created_at)} ago", post %>
Don't know why it didn't work for you. Any code samples?
Try:
<%= link_to "#{distance_of_time_in_words_to_now(post.created_at)} ago", post %>
Also, the block syntax for long links:
<%= link_to post do %>
<%= distance_of_time_in_words_to_now(post.created_at) %> ago
<% end %>
You could easily add an icon here, for example.
On a side note, it also doesn't add a horizontal scrollbar to StackOverflow's layout :)
精彩评论