# Help with this code

**URL:** <https://discuss.rubyonrails.org/t/help-with-this-code/14414>\
**Category:** rubyonrails-talk\
**Created:** [June 14, 2007, 3:40pm UTC](https://discuss.rubyonrails.org/t/help-with-this-code/14414 "2007-06-14T15:40:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugh\_Sasse](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@Hugh\_Sasse](https://discuss.rubyonrails.org/u/Hugh_Sasse)\
**Post date:** [June 14, 2007, 3:40pm UTC](https://discuss.rubyonrails.org/t/help-with-this-code/14414/1 "2007-06-14T15:40:26Z")

</div>

Assignment from 'here document' (document directly embedded in the source)

[http://ruby.about.com/od/learnruby/p/here\_document.htm](http://ruby.about.com/od/learnruby/p/here_document.htm)

has examples.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hugh

---

<div class="post-metadata">

**Author:** ![Daniel\_N](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@Daniel\_N](https://discuss.rubyonrails.org/u/Daniel_N)\
**Post date:** [June 15, 2007, 4:22am UTC](https://discuss.rubyonrails.org/t/help-with-this-code/14414/2 "2007-06-15T04:22:37Z")

</div>

this is because your display\_products returns category.productos which is an Array (sort of)

This is the last statement in your method. The each loop is basically spinning it’s wheels.

ret = “

- 

”

At the end of the block you have a string. But you don’t do anything with it.

Perhaps if you collected the results of each loop in an array and then joined them. eg

def display\_products(category)

```
category.productos.map do |p|

    ret = "<li>"

    ret << link_to_remote( "<span>#{p.nombre}</span>",

                    :url=>{:action

```

=\> “prod\_id”, :id =\> [p.id](http://p.id)},

```
                    :update

```

=\> ‘info’)

```
    ret << "</li>"

end.join

```

end

This would return the finished string at the end of the method.

There has to be a cleaner way though. Like just appending to the view buffer directly.

Hope this helps

Daniel
