Hi, I''m having a problem trying to create a form that can populated nested objects. In my main object, WG, I have two lists of objects: A objects, and B objects. I want to display a form where I can select an arbitrary number of A objects with checkboxes, and a single B object with radio buttons. The problem is that when I try to do a form for the WG object, I get hungup on what attributes to use in w.check_box(). I''ve added a "selected" attribute to the A and B objects and was thinking I could use that, but when I do something like: form_for(:wg) do |w| w.a_list.each do |a| w.check_box(<something that points to w.a.selected>, {}, true, false) end end I keep hitting nil objects and syntax errors. Any ideas? Did I explain myself clear enough? Thanks, Ryan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> form_for(:wg) do |w| > w.a_list.each do |a| > w.check_box(<something that points to w.a.selected>, {}, true, > false) > end > end > > I keep hitting nil objects and syntax errors. > > Any ideas? Did I explain myself clear enough?use field_for for the separate a & b objects then in the controller add them to each of their association collections of the wg object -- 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 -~----------~----~----~----~------~----~------~--~---
That looks right. I searched around for field_for which appears to be a typo. I found fields_for, and an explanation of similar to what I''m trying to do here: http://railsforum.com/viewtopic.php?id=719 Thanks On 9/13/07, Anthony Green <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > > form_for(:wg) do |w| > > w.a_list.each do |a| > > w.check_box(<something that points to w.a.selected>, {}, true, > > false) > > end > > end > > > > I keep hitting nil objects and syntax errors. > > > > Any ideas? Did I explain myself clear enough? > > use field_for for the separate a & b objects then in the controller add > them to each of their association collections of the wg object > > > -- > 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 -~----------~----~----~----~------~----~------~--~---