# How can I do that in one line?

**URL:** <https://www.ruby-forum.com/t/how-can-i-do-that-in-one-line/132938>\
**Category:** Rails\
**Created:** [March 25, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/how-can-i-do-that-in-one-line/132938 "2008-03-25T23:08:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 25, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/how-can-i-do-that-in-one-line/132938/1 "2008-03-25T23:08:21Z")

</div>

I have a select list with this code:

 \<% @products.each do |product| %\> \> \<%= product.name%\> \<% end %\>

In this select list the user can see the product names. I think it is  
possible to do that in one line. How can I do that?

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 25, 2008, 11:32pm UTC](https://www.ruby-forum.com/t/how-can-i-do-that-in-one-line/132938/2 "2008-03-25T23:32:35Z")

</div>

John S. writes:

> In this select list the user can see the product names. I think it  
> is  
> possible to do that in one line. How can I do that?

I beleive the SELECT ActionView Helper is what you are looking for.

– Long  
[http://FATdrive.tv/wall/trakb/10-Long](http://FATdrive.tv/wall/trakb/10-Long)  
[http://FATdrive.tv/](http://FATdrive.tv/) - store, play, share

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 25, 2008, 11:37pm UTC](https://www.ruby-forum.com/t/how-can-i-do-that-in-one-line/132938/3 "2008-03-25T23:37:19Z")

</div>

Le 25 Mar 2008 à 22:08, John S. a écrit :

> 

something like collection\_select :ticket, :product\_id,  
@products, :id, :name  
should do the trick.

Fred
