I want to have a form that adds new groups of the same input fields via link_to_remote. I then want to collect those groups and insert them all into the database. So if I have a database that''s for groups of flashcards, with the card id as the primary key, then I want to gather up the groups and insert them at one time, looking something like this. <form action="newDeck"> <%=link_to_remote("add Flash Card!", :url => {:action => "addAnotherCard"}) %> #this will update the "deck div" <div class="deck"> #adds a card partial from an rjs template <div class="card"> question: <input name="Deck[question]" /> answer: <input name="Deck[answer]" /> </div> #adds another card etc... <div class="card"> question: <input name="Deck[question]" /> answer: <input name="Deck[answer]" /> </div> </div> <input type="submit" value="make a deck!" /> </form> I don''t have any problems adding the input fields, but I''m looking for a way to identify the "card divs" with unique id''s, for if I wanted to remove the elements, and I''m also trying to figure out how to get these redundant fields in the database through one form. I''m looking around to see if I can increment and assign a number id to the card div each time a card is added, but no luck so far. any help would be great! -- 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 -~----------~----~----~----~------~----~------~--~---
can anyone help here? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Sean, Briefly, you need to pass the collection of cards into a view (like list.rhtml) and within that view iterate through the collection and generate a partial for each card. Keep track of the ''card number'' and use it to assign the divs'' ids. So your partial will have a line like... <div id=<%= @card_num.to_s %> class=''card''> Got to run for now. Holler back if you need more help. ill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> Hi Sean, > > Briefly, you need to pass the collection of cards into a view (like > list.rhtml) and within that view iterate through the collection and > generate > a partial for each card. Keep track of the ''card number'' and use it to > assign the divs'' ids. So your partial will have a line like... > > <div id=<%= @card_num.to_s %> class=''card''>Slight alteration in case you have multiple classes that may be manipulated: <div id="card-<%= @card_num.to_s %>" class=''card''> You will also need to tag the input fields with different id''s so they don''t stomp on each other (do this in your partial), eg: <div id="card-1" class="card"> question: <input name="Deck[1][question]" /> answer: <input name="Deck[1][answer]" /> </div> <div id="card-2" class="card"> question: <input name="Deck[2][question]" /> answer: <input name="Deck[2][answer]" /> </div> -- 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 -~----------~----~----~----~------~----~------~--~---