I noticed the d开发者_C百科ocs have:
<%= item_counter %>
But I have a partial which I want to add a class into on every 6th one, is there an easy way to do this?
You can pass variables into the partial's instance scope when you call it, and inside the partial you can then take action based on the value of those instance variables.
So if you have the local variable item_counter in the view containing the partial, render the partial like this:
<%= render :partial => "my_partial", :locals => { :item_counter => item_counter} %>
Inside the partial, you will now be able to access the local variable item_counter. Thus inside the partial you could have:
if item_counter > 0 && item_counter % 6 == 0
# Do exciting base 6 activity
end
精彩评论