Help with f.select

I have this code in my new view:

<p>
   <b>Product</b><br />
  <select name="repair_ticket[product_id]">
   <% @products.each do |product| %>
       <option value="<%= product.id %>"
         <%= ' selected' if product.id == @repair_ticket.product_id %>>
         <%= product.name%>
       </option>
   <% end %>
  </select></p>

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.

John Smith wrote:

I have this code in my new view:

<p>
   <b>Product</b><br />
  <select name="repair_ticket[product_id]">
   <% @products.each do |product| %>
       <option value="<%= product.id %>"
         <%= ' selected' if product.id == @repair_ticket.product_id %>>
         <%= product.name%>
       </option>
   <% end %>
  </select></p>

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.

Nathan Esquenazi wrote:

John Smith wrote:

I have this code in my new view:

<p>
   <b>Product</b><br />
  <select name="repair_ticket[product_id]">
   <% @products.each do |product| %>
       <option value="<%= product.id %>"
         <%= ' selected' if product.id == @repair_ticket.product_id %>>
         <%= product.name%>
       </option>
   <% end %>
  </select></p>

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.

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

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

Nathan Esquenazi wrote:

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

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.