2011-03-23 80 views

回答

1

对于论坛申请我这样做:

<td class="right"> 
    <% if forum.most_recent_post %><%= distance_of_time_in_words_to_now forum.most_recent_post.last_post_at %> ago by <%= link_to forum.most_recent_post.user.login, "https://stackoverflow.com/users/#{forum.most_recent_post.last_poster_id}" %> 
    <% else %> no posts <% end %> 
</td> 

这里<%= distance_of_time_in_words_to_now forum.most_recent_post.last_post_at %>前的“用户名”,因此,您可以尝试这个。我认为这也可以在这种情况下工作。只需在这里使用distance_of_time_in_words_to_now post.time post.time是用户发布帖子的时间。

+0

嗨我试过的代码,但它说,我有一个未定义的方法“distance_of_time_in_word_to_now”任何帮助? – ChrisBedoya 2011-03-27 20:18:59

+0

Nvm。我最终添加了这个:<%= link_to“#{distance_of_time_in_words_to_now(post.created_at)} ago”,post%>,它工作的很完美!... – ChrisBedoya 2011-03-27 20:31:15

+0

@ChrisBedoya - 在我的情况下,上面的代码工作,所以我粘贴那个:P,好吧,如果它按照你在评论中提到的方式工作,欢呼...... :) – Surya 2011-03-28 06:05:49