-1
我越來越想使用時,奇怪的錯誤‘time_ago_in_words’功能在軌conversation.messages.first(created_at):未定義的方法`> time_ago_in_words’Rails中
<% conversations.each do |conversation| %>
<% user_status = current_user.id == conversation.sender.id ? conversation.recipient : conversation.sender %>
<li>
<%= gravatar_for(user_status, size: 50) %>
<%= link_to user_status.email, conversation_messages_path(conversation),
remote: true,
class: "conversation-names #{'current-link' if conversation == conversations.first}" %>
<span class="delete-message"><%= link_to do %><i class="fa fa-times"></i><% end %></span>
<p><%= truncate(conversation.messages.first.try(:body)) %><%= time_ago_in_words conversation.messages.first.try(:created_at) %></p>
</li>
<% end %>
未定義的方法`>'爲零:NilClass。
'conversation.messages'必須爲空,因此'first'返回'nil' – Iceman