Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Last active December 26, 2015 01:59
Show Gist options
  • Save blairanderson/7075515 to your computer and use it in GitHub Desktop.
Save blairanderson/7075515 to your computer and use it in GitHub Desktop.
rendering a collection to a partial, but I want to have the layout be different for even and odd records that are rendered out. https://gist.github.com/blairanderson/7075515
<% if thing_counter.even? %>
<div class="wide">
<h2>Header</h2>
<p class="lead"></p>
</div>
<div class="narrow">
<%= image_tag thing.image %>
</div>
<% else %>
<div class="narrow">
<%= image_tag thing.image %>
</div>
<div class="wide">
<h2>Header</h2>
<p class="lead"></p>
</div>
<% end %>
<%= render partial: 'thing', collection: @some_pictures_or_things %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment