# Using Array.each in a helper

**URL:** <https://www.ruby-forum.com/t/using-array-each-in-a-helper/131288>\
**Category:** Rails\
**Created:** [March 7, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/using-array-each-in-a-helper/131288 "2008-03-07T17:47:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [March 7, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/using-array-each-in-a-helper/131288/1 "2008-03-07T17:47:56Z")

</div>

hi all,

I’m trying to do a each on an array the droppable element  
\<%= draggable\_element “user\_” + create\_drop\_zone(zone),  
:revert =\> true,  
:onStart =\> “function(){” %\>  
\<% drop\_zone\_ids.each do |  
zone| %\>  
Element.addClassName(’\<%=  
zone %\>’, ‘border’);  
\<% end %\>  
Element.addClassName(‘user\_\<%=  
user\_node %\>’, ‘move\_user’); }

This results in:  
//  
  
Element.addClassName(‘3’, ‘border’);  
Element.addClassName(‘4’, ‘border’);  
Element.addClassName(‘user\_1\_4’, ‘move\_user’); }

Someone knows how to solve this?

thanks  
Stijn

---

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [March 7, 2008, 8:25pm UTC](https://www.ruby-forum.com/t/using-array-each-in-a-helper/131288/2 "2008-03-07T20:25:07Z")

</div>

Hi –

On Fri, 7 Mar 2008, Tarscher wrote:

> zone %\>', ‘border’);  
> Element.addClassName(‘4’, ‘border’);  
> Element.addClassName(‘user\_1\_4’, ‘move\_user’); }

You need to drop down to regular Ruby string interpolation. Try this:

\<%= draggable\_element “user\_” + create\_drop\_zone(zone),  
:revert =\> true,  
:onStart =\> "function(){#{  
drop\_zone\_ids.map do |zone|  
“Element.addClassName(‘#{zone}’, ‘border’);  
Element.addClassName(‘user\_#{user\_node}’, ‘move\_user’);  
"  
end}  
}” %\>

David

–  
Upcoming Rails training from David A. Black and Ruby Power and Light:  
ADVANCING WITH RAILS, April 14-17 2008, New York City  
CORE RAILS, June 24-27 2008, London (Skills Matter)  
See [http://www.rubypal.com](http://www.rubypal.com) for details. Berlin dates coming soon!
