# Executing an ERB snippet in an array (?)

**URL:** <https://www.ruby-forum.com/t/executing-an-erb-snippet-in-an-array/145991>\
**Category:** Rails\
**Created:** [August 15, 2008, 9:52pm UTC](https://www.ruby-forum.com/t/executing-an-erb-snippet-in-an-array/145991 "2008-08-15T21:52:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paco.onrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/fbc32d/32.png) [@paco.onrails](https://www.ruby-forum.com/u/paco.onrails)\
**Post date:** [August 15, 2008, 9:52pm UTC](https://www.ruby-forum.com/t/executing-an-erb-snippet-in-an-array/145991/1 "2008-08-15T21:52:08Z")

</div>

Hi again, I have a problem attempting to execute a ERB snippet saved  
in an array.  
In the controller I have an array like this one:

@my\_objects=[[‘Name Object 1’,’\<%=another\_array\_iterator.name%\>’],  
[‘Name Object 1’,’\<%=another\_array\_iterator.description%\>’], [‘Name  
Object 1’,’\<%=another\_array\_iterator.value%\>’] ]

And in the view I like to do something like this:

```
        <thead>
            <tr>
     <% for t in @my_objects%>
     <th><%=t[0]%></th>
     <% end %>
            </tr>
        </thead>
        <tbody>
            <tr>
     <% for t in @my_objects%>
     <th><%=t[1]%></th>
     <% end %>
            </tr>
        </tbody>

```

And of course that this doesn’t work because rather than execute the  
ERB snippet in the array is just putting it.  
How can I execute an ERB snippet saved in an array rather than just  
printing it?

Thanks!!!
