我有一個部分的條件相對較深,我很好奇這是否適合部分?如何重構我的Rails部分?
根據遊戲日期是否與今天的日期相匹配,我騎自行車遊戲並打印YES或NO。
<% i = 0 %>
<% x = 0 %>
<% @games.each do |game| %>
<% if game.date.strftime("%_m/%d")[1..-1] == today %>
YES!
<% i = 1 %>
<% else %>
<% unless i == 1 %>
NO!
<% i = 1 %>
<% x = 1 %>
<%= next_game %>
<% end %>
<% end %>
<% end %>
謝謝!
謝謝保羅。很有幫助。 – reknirt