-1
在我的索引中我有@ date.day,當我使用@ date.strftime(「%B%Y」)時,它工作得很好。在rails中使用strftime時出錯
但是在代碼中還有一個小問題,我有aula.time2。 它讓我喜歡「2000-01-01 10:00:00 UTC」,這是醜陋的。 但如果我嘗試打印aula.time2.strftime(「%I%M」)它不會工作。
它給了我這個錯誤: 未定義的方法`strftime的」爲無:NilClass
什麼想法?
指數:
<div id="articles">
<h2 id="month">
<%= link_to "<", date: @date.prev_week %>
<%= @date.strftime("%B %Y") %>
<%= link_to ">", date: @date.next_week%>
</h2>
<%= calendar @date do |date| %>
<%= date.day %>
<% if @aulas_by_date[date] %>
<ul>
<% @aulas_by_date[date].each do |aula| %>
<%= aula.time2.strftime("%I %M") %>
</div>
<% end %>
</ul>
<% end %>
<% end %>
你確定所有的aulas不是零? –
是的。就是這樣! 謝謝你! – Allan