今回は、大げさな機能ではないですが、 知っているとちょっと便利なHelper関数を紹介します。 cycle まずはcycle。これはCSSのクラスにeven, oddを指定する場合のような、 周期的に繰り返す文字列を簡単に埋め込むことが出来ます。 1 @items = [1,2,3,4] 2 <table> 3 <% @items.each do |item| %> 4 <tr class="<%= cycle("even", "odd") -%>"> 5 <td>item</td> 6 </tr> 7 <% end %> 8 </table>