# Help with f.select

**URL:** <https://www.ruby-forum.com/t/help-with-f-select/127144>\
**Category:** Rails\
**Created:** [January 25, 2008, 12:37pm UTC](https://www.ruby-forum.com/t/help-with-f-select/127144 "2008-01-25T12:37:33Z")\
**Posts on this page:** 5\
**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:** [January 25, 2008, 12:37pm UTC](https://www.ruby-forum.com/t/help-with-f-select/127144/1 "2008-01-25T12:37:33Z")

</div>

I have this code in my new view:

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

I have many products, so when I click to show my products and then  
select one, I obtain a huge list. I would like only to show 5 or more of  
my list and then have a sidebar in this list so I can roll down the  
list and select one.

---

<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:** [January 25, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/help-with-f-select/127144/2 "2008-01-25T12:52:07Z")

</div>

John S. wrote:

> I have this code in my new view:
> 
> **Product**  
> \<% @products.each do |product| %\> \> \<%= product.name%\> \<% end %\>
> 
> I have many products, so when I click to show my products and then  
> select one, I obtain a huge list. I would like only to show 5 or more of  
> my list and then have a sidebar in this list so I can roll down the  
> list and select one.

Well this should be easy to do.

option 1) do a limit on your find operation:

@products = Product.find(:all, :limit =\> 5)

or option 2) simply grab the first 5 from the array

@products = Product.find(:all, :limit =\> 5)  
first\_five = @products[0…4]

either way that will get you the first five to display.

---

<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:** [January 25, 2008, 1:06pm UTC](https://www.ruby-forum.com/t/help-with-f-select/127144/3 "2008-01-25T13:06:53Z")

</div>

Nathan E. wrote:

> John S. wrote:
> 
> > I have this code in my new view:
> > 
> > **Product**  
> > \<% @products.each do |product| %\> \> \<%= product.name%\> \<% end %\>
> > 
> > I have many products, so when I click to show my products and then  
> > select one, I obtain a huge list. I would like only to show 5 or more of  
> > my list and then have a sidebar in this list so I can roll down the  
> > list and select one.
> 
> Well this should be easy to do.
> 
> option 1) do a limit on your find operation:
> 
> @products = Product.find(:all, :limit =\> 5)
> 
> or option 2) simply grab the first 5 from the array
> 
> @products = Product.find(:all, :limit =\> 5)  
> first\_five = @products[0…4]
> 
> either way that will get you the first five to display.

Thanks, but I mean another thing. If i do what you suggested, I only  
display de 5 first ones, and never display the other ones. I want to  
display only five and with a bar be able to scroll down and see the  
other ones.

---

<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:** [January 25, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/help-with-f-select/127144/4 "2008-01-25T13:37:38Z")

</div>

I will give it another try. Are you referring to wanting a paginated  
list?

[http://rock.errtheblog.com/will\_paginate](http://rock.errtheblog.com/will_paginate)

Pagination basically displays only 5 at once or whatever, but allows you  
to shift and see all of them by browsing through pages…

if I missed it again I will let someone else answer

---

<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:** [January 25, 2008, 5:06pm UTC](https://www.ruby-forum.com/t/help-with-f-select/127144/5 "2008-01-25T17:06:55Z")

</div>

Nathan E. wrote:

> I will give it another try. Are you referring to wanting a paginated  
> list?
> 
> [http://rock.errtheblog.com/will\_paginate](http://rock.errtheblog.com/will_paginate)
> 
> Pagination basically displays only 5 at once or whatever, but allows you  
> to shift and see all of them by browsing through pages…
> 
> if I missed it again I will let someone else answer

Ok, it was another problem, but it’s already solved. Thanks for your  
help.
