What I Learned Today About ActionView

I ran across a couple of ActionView tidbits that were new to me, so I thought I’d share.

You can comment out ERb delimiters in your view by adding a pound sign before the equal sign.


<%#= str %>

When rendering a collection, you have access to a zero-based “partial_counter” variable that increments on each iteration.


<%= div_for(entry) do %>
	<%= entry_counter %>
<% end  %>

Todays lesson brought you by chapter 10 of “The Rails Way” by Obie Fernandez.