title: How to run a Bootstrap Carousel loop for indicator data_slide_to
body: <p>I got a Carousel with picture thumbnail indicators from here: <a href="https://gist.github.com/talmand/9695563" rel="nofollow">https://gist.github.com/talmand/9695563</a></p>
  
  <p>I'm using a 'do' <code>loop</code> to insert pictures and have figured out most of it but I run into an issue with the <code>data-slide-to</code> part of it.  I don't want a hard-coded number in there, as I want it to respond based on the number of pictures that have been uploaded, and obviously what index that picture is in the array.  What solution would work here? Relevant code below (I bolded the key part)</p>
  
  <p>properties/show:</p>
  
  <pre><code>&lt;div class='carousel-inner'&gt;
                      &lt;% @property_attachments.each do |pic| %&gt;
                          &lt;div class='item &lt;%= "active" if pic == @property_attachments.first %&gt;' &gt;
                              &lt;%= image_tag(pic.picture) %&gt;
                          &lt;/div&gt;
                      &lt;% end %&gt;                       
                  &lt;/div&gt;&lt;!--/.carousel-inner--&gt;
  ...
  
  &lt;ol class='carousel-indicators'&gt;
                  &lt;% @property_attachments.each do |thumb| %&gt;
                      &lt;li data-target='#carousel-custom' **data-slide-to='0'** class='&lt;% 'active' if thumb == @property_attachments.first %&gt;' &gt;
  &lt;%= image_tag(thumb.picture) %&gt;&lt;/li&gt;    
                  &lt;% end %&gt; 
              &lt;/ol&gt;
  </code></pre>
  
  <p>properties controller: </p>
  
  <pre><code>def show
  @property_attachments = @property.property_attachments.all
  end
  </code></pre>