<bill-4qJMilvFZdi/7u6bA4Lga2Xnswh1EIUO@public.gmane.org>
2005-Aug-30 02:44 UTC
array to table??
Can someone help a newbie here. Trying to learn Ruby and rails at the same time is troublesome. I tried looking for this in the pick axe and rails books and could find an answer to my problem. I have an array called @labelArr that has n number of elements and I want to add each element of the array to a table called Labels that has two fields (id & label) can someone help me with how I would do this? thanks, -bill
Bill, In your view, iterate over your array and put the appropriate data where you like it: <table> <% for label in @labelArr %> <tr> <td><%= label %></td> </tr> <% end %> </table> Or something of the sort. -- Mando On 8/29/05, bill-4qJMilvFZdi/7u6bA4Lga2Xnswh1EIUO@public.gmane.org <bill-4qJMilvFZdi/7u6bA4Lga2Xnswh1EIUO@public.gmane.org> wrote:> > Can someone help a newbie here. Trying to learn Ruby and rails at the same > time is troublesome. I tried looking for this in the pick axe and rails > books and could find an answer to my problem. > > I have an array called @labelArr that has n number of elements and I want > to add each element of the array to a table called Labels that has two > fields (id & label) can someone help me with how I would do this? > > > thanks, > > -bill > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails