magic6435-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Sep-26 14:36 UTC
With partial in a block is there any way to face "cycle" to restart?
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. [code] <div class="banner <%= cycle :left, :center, :right %>"> [/code] But then i split it up to also display the category name like so. [code] <% @categories.each do |category| %> <div class="category"> <h3><%= category.name %></h3> <%= render :partial => "/shared/banner", :collection => category.products %> </div> <% end %> [/code] 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Sep-26 14:38 UTC
Re: With partial in a block is there any way to face "cycle" to restart?
On Sep 26, 3:36 pm, "magic6...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <magic6...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---