title: How to display a certain number of array items in rails
body: <p>I have an array and I want to display only 4 items at a time and when I click on Next it will display the 4 next items.
  View Code :</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th&gt;3&lt;/th&gt;
    &lt;th&gt;2&lt;/th&gt;
    &lt;th&gt;1&lt;/th&gt;
    &lt;th&gt;1&lt;/th&gt;
    &lt;th&gt;2&lt;/th&gt;
    &lt;th&gt;3&lt;/th&gt;
    &lt;th&gt;&lt;/th&gt;
  
  &lt;/tr&gt;
  &lt;% count = 0 %&gt; 
  &lt;% while count &lt; 4%&gt;
    &lt;tr class="match_row" value="&lt;%=count%&gt;"&gt;
      &lt;th id="left_competitor"&gt;&lt;%= @matches[count][0].title %&gt;&lt;/th&gt;
      &lt;% (1..6).each do |i|%&gt;
        &lt;th&gt;  &lt;input type="radio" class="group_&lt;%=count%&gt;" name="&lt;%=count%&gt;" value="&lt;%= i%&gt;"&gt;&lt;br&gt;&lt;/th&gt;
      &lt;% end %&gt;
      &lt;th id="right_competitor"&gt; &lt;%= @matches[count][1].title %&gt;&lt;/th&gt;
    &lt;/tr&gt;
    &lt;br /&gt;
    &lt;% count += 1 %&gt;
  &lt;% end %&gt;
  &lt;br /&gt;
  &lt;/table&gt;
  &lt;input id="save_votes" type="button" value="Next"&gt;
  </code></pre>
  
  <p>Now here is the CoffeeScript code :</p>
  
  <pre><code>move_to_next_match = -&gt;
    $("#save_votes").click -&gt; display_next_competitors()
  
  display_next_competitors = -&gt;
    project_id = document.getElementById("project_id").value
    match_rows = $('.match_row')
    results = []
    for i in [0...match_rows.length]
      do (i) -&gt;
        radios = $(".group_#{i}")
        for j in [0...radios.length]
          do (j) -&gt;
            if radios[j].checked
              count = radios[j].getAttribute 'name'
              number = radios[j].getAttribute 'value'
              results.push("#{count} #{number}")
    data = "{\"get_matches_results\": \"#{results}-#{project_id}-#{marker}\"}"
    $.ajax({
    type: "POST"
    url: "projectss/pca_results"
    data: "data=" + data
    })
    location.reload(true);
  </code></pre>
  
  <p>My idea is to let the variable count in view (&lt;%count = 0%>) take the value of a variable instead of 0 but I can't figure out how to do this.
  Any ideas ?</p>