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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 answerOk, it was another problem, but it''s already solved. Thanks for your help. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---