I have a select list with this code: <select name="ticket[product_id]"> <% @products.each do |product| %> <option value="<%= product.id %>" <%= '' selected'' if product.id == @ticket.product_id %>> <%= product.name%> </option> <% 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? -- 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 -~----------~----~----~----~------~----~------~--~---
Le 25 Mar 2008 à 22:08, John Smith a écrit :> > I have a select list with this code: > > <select name="ticket[product_id]"> > <% @products.each do |product| %> > <option value="<%= product.id %>" > <%= '' selected'' if product.id == @ticket.product_id %>> > <%= product.name%> > </option> > <% end %> >something like collection_select :ticket, :product_id, @products, :id, :name should do the trick. Fred> 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? > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John Smith writes:> > I have a select list with this code: > > <select name="ticket[product_id]"> > <% @products.each do |product| %> > <option value="<%= product.id %>" > <%= '' selected'' if product.id == @ticket.product_id %>> > <%= product.name%> > </option> > <% end %> > > In this select list the user can see the product names. I think itis> 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/ - store, play, share --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---