Resets a cycle so that it starts from the first element the next time it is called. Pass in name to reset a named cycle.
Example
# Alternate CSS classes for even and odd numbers... @items = [[1,2,3,4], [5,6,3], [3,4,5,6,7,4]] <table> <% @items.each do |item| %> <tr class="<%= cycle("even", "odd") -%>"> <% item.each do |value| %> <span style="color:<%= cycle("#333", "#666", "#999", :name => "colors") -%>"> <%= value %> <% end %> <% reset_cycle("colors") %> <% end %> </table>
Source Code
# File action_view/helpers/text_helper.rb, line 419 def reset_cycle(name = "default") cycle = get_cycle(name) cycle.reset unless cycle.nil? end
<code/>and<pre/>for code samples.