How to loop through each Post in Rails while changing the class each time

Viewed 833

I'm trying to loop through each Post in a Rails app where the class changes each time. Here's the layout in HTML, how would I create this in a rails <% @posts.each do |post| %> loop. The css classes go from style1 to style 6

  <article class="style1">
    <span class="image">
      <img src="images/pic01.jpg" alt="" />
    </span>
    <a href="generic.html">
      <h2>Magna</h2>
      <div class="content">
        <p>Sed nisl arcu euismod sit amet nisi lorem etiam dolor veroeros et feugiat.</p>
      </div>
    </a>
  </article>
  <article class="style2">
    <span class="image">
      <img src="images/pic02.jpg" alt="" />
    </span>
    <a href="generic.html">
      <h2>Lorem</h2>
      <div class="content">
        <p>Sed nisl arcu euismod sit amet nisi lorem etiam dolor veroeros et feugiat.</p>
      </div>
    </a>
  </article>

etc...

3 Answers
Related