[Rails] templates and arrays
zdennis
zdennis at mktec.com
Wed Dec 14 14:33:57 GMT 2005
Tom Fakes wrote:
> The best way to do this is:
>
> <% products.each_with_index { |product, index| %>
> <%= product.size %>
> <% } %>
>
I would use the do/end syntax in place of the { } since you are having it span multiple lines, and
since embedded in html. It is somewhat ambiguous because hashes can be created with {}.
<% products.each_width_index do |product,index| %>
<%= product.size %>
<% end %>
I think 'end' in embedded in HTML also gives a better visual for way a code block stops in ruby.
Zach
More information about the Rails
mailing list