views:

119

answers:

1

A first look I thought erb accepts any Ruby code, but I've got this strange behaviour...

I have an array [of tags for my article], and I want to make a nice display for them. So I'm writing something like this:

<ul>
   <% @post.tags.each do |item| %> 
   <li>item</li>
   <% end %>
</ul>

The wrong output looks like this:

<ul>
   <li>item</li>
   <li>item</li>
   <li>item</li>
   ...
</ul>

Where I am wrong? Any suggestions how to make a proper iteration?

+4  A: 

You forgot the <%= %> to display the value of item:

<ul>
   <% @post.tags.each do |item| %> 
   <li><%= item %></li>
   <% end %>
</ul>
molf
Gosh, thanks a lot =)
gmile