<div class="postSlideshowDots">
<%for i in @post.images%>
<%=render :partial => "dots", :locals => {:image => i }%>
<%end%>
</div>
I would like to also pass in a variable (=0 when it goes in) to use as a counter. I had read that there was one already built in, “partialname_counter”, but that gave me an error.
use
<%= render :partial => "dots", :collection => @post.images %>, and you will get a variable calleddots_counterin the partial. You will also need to change your partial to usedotsinstead ofimageas the variable.Finally, don’t use
for..inin Ruby, it is non-idiomatic, and has some bad behavior in regards to closures and scoping. Use.each