我循環通過ID的數組,像這樣:Rails的循環不顯示重複的字符串
<% @tip.horse_ids.each do |i| %>
<% @horse = Horse.find(i) %>
<%= @horse.race.meeting.racecourse.strip %><br />
<%= @horse.race.time.to_s(:time) %> - <%= @horse.name.strip %><br />
<% end %>
,其輸出是這樣的:
Kempton (AW)
01:30 - Light Gunner
Kempton (AW)
01:30 - Mesophere
Kempton (AW)
01:30 - Ragtag Rascal
Kempton (AW)
01:30 - Many Waters
Kempton (AW)
02:40 - Judicial
Stratford
01:40 - Rabunda
Stratford
我只想要「肯普頓( AW)「在循環中出現一次(第一次),同樣的時間,所以」1:30「應該只出現一次我也想刪除所有重複的內容。任何幫助將不勝感激,謝謝!