# With partial in a block is there any way to face "cycle" to restart?

**URL:** <https://www.ruby-forum.com/t/with-partial-in-a-block-is-there-any-way-to-face-cycle-to-restart/149591>\
**Category:** Rails\
**Created:** [September 26, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/with-partial-in-a-block-is-there-any-way-to-face-cycle-to-restart/149591 "2008-09-26T16:45:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magic6435](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@magic6435](https://www.ruby-forum.com/u/magic6435)\
**Post date:** [September 26, 2008, 4:45pm UTC](https://www.ruby-forum.com/t/with-partial-in-a-block-is-there-any-way-to-face-cycle-to-restart/149591/1 "2008-09-26T16:45:21Z")

</div>

Im trying to display lists of products on a page which is split up  
into categories which is fine but, the way they are displayed is in a  
3xwhatever grid so i was using cycle in my partial to set css styles  
for the spacing.

```auto
<div class="banner <%= cycle :left, :center, :right %>">
```

But then i split it up to also display the category name like so.

```auto
<% @categories.each do |category| %>
  <div class="category">
    <h3><%= category.name %></h3>
    <%= render :partial => "/shared/banner", :collection =>
category.products %>
  </div>
<% end %>
```

Problem is. the cycle does not “restart” after each loop of the block  
so they get out of order if a preceding category has an even number of  
products. is there any way to force the cycle back to “left” after  
each pass?

Thanks. mike

---

<div class="post-metadata">

**Author:** ![magic6435](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@magic6435](https://www.ruby-forum.com/u/magic6435)\
**Post date:** [September 26, 2008, 4:52pm UTC](https://www.ruby-forum.com/t/with-partial-in-a-block-is-there-any-way-to-face-cycle-to-restart/149591/2 "2008-09-26T16:52:26Z")

</div>

On Sep 26, 3:36 pm, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Problem is. the cycle does not “restart” after each loop of the block  
> so they get out of order if a preceding category has an even number of  
> products. is there any way to force the cycle back to “left” after  
> each pass?

reset\_cycle

Fred
