On Tue, Nov 9, 2010 at 9:15 AM, Marnen Laibow-Koser <[email protected]>wrote:
> Hanan Y. wrote in post #960326: > > Hi all, > > i'v been trying to understand how can i add more then one record to the > > DB from a form in a single shot so to say.. > > I have an ITEM module, it has an ItemID and TYPEofItem , the TypeofItem > > is been selected from a dropdown list that populates the item types i > > have in another module *(called Types).. > > I have everything working nicly and i am adding the ItemID with no > > problem, > > but! i am trying to understand if i can type in more then one ItemID > > (with the same ItemType value) and submitting them all at once to the > > DB.. > > Maby crating a list object (i have no idea on how to do that in the > > view..) and filling out rows with differnt ID's and then running on the > > list and adding them all... > > Can someone please help me understand how to do that ? - thank's... > > You want to use accepts_nested_attributes_for. > I literally yesterday followed two railscasts which will get you up to speed with this: http://railscasts.com/episodes/196-nested-model-form-part-1 http://railscasts.com/episodes/197-nested-model-form-part-2 Note that if you are using Rails 3 you will have to remove the "h(...)" in the helper method. If you run into trouble post back here as I just got this working and is pretty slick. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > [email protected] > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

