I have had the worst time getting my forms to accept input for more than one model. I tried using accepts_nested, and other techniques and finally got it all working. But it was not fun. I never did get accepts_nested working! I do need more experience. I did hit upon one idea that I just wanted to run by the community. Let me know what you think. If you have one form that will need to send values to several models.... how about creating a "Form" model with generic attributes. This "Form" model could for example have fields integer1:integer, integer2:integer ... etc.. and have fields string1:string, string2:string..... etc.. You would build a "Form" model that could handle any form in your site. Then you just collect the values into this "Form" model.. after they are in you just assign them to all your other models. No need to go crazy with all those parameters[][:this][:that]. It for sure may not be the MOST efficient way to deal with the database, but it can''t be that bad. Thoughts? Shawn -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Shawn, If you''re doing something in Rails and it''s "not fun" then chances are you can be doing it a better way! Using accepts_nested with appropriate relationship declarations will eliminate going "crazy with all those parameters[][:this][:that]". I highly recommend you work with accepts_nested. There are plenty of resources out there to help you along the way. It will bring back the fun. Matt On May 7, 7:52 pm, slindsey3000 <slindsey3...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have had the worst time getting my forms to accept input for more > than one model. I tried using accepts_nested, and other techniques > and finally got it all working. But it was not fun. I never did get > accepts_nested working! > > I do need more experience. > > I did hit upon one idea that I just wanted to run by the community. > Let me know what you think. > > If you have one form that will need to send values to several > models.... how about creating a "Form" model with generic attributes. > This "Form" model could for example have fields integer1:integer, > integer2:integer ... etc.. and have fields string1:string, > string2:string..... etc.. > > You would build a "Form" model that could handle any form in your > site. > > Then you just collect the values into this "Form" model.. after they > are in you just assign them to all your other models. No need to go > crazy with all those parameters[][:this][:that]. > > It for sure may not be the MOST efficient way to deal with the > database, but it can''t be that bad. > > Thoughts? > > Shawn > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
"slindsey3000" <slindsey3000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote in message news:ac0ebe39-e6e3-48df-8ed9-9b4ab029c181-DyKnQJVamazCR6KFjlihX2B/v6IoIuQBratpaaBEXXs@public.gmane.org>I have had the worst time getting my forms to accept input for more > than one model. I tried using accepts_nested, and other techniques > and finally got it all working. But it was not fun. I never did get > accepts_nested working! >To help you get accepts_nested working, since that is so much easier than the alternatives if you can get it working, please watch the following railscast: http://railscasts.com/episodes/196-nested-model-form-part-1 If you have a strong aversion to watching a screencast, you may instead substitue the asciicast: http://asciicasts.com/episodes/196-nested-model-form-part-1 That should be enough to get accepts_nested_attributes_for working, at least in the way it was intended to work. If you have further questions after watching that, please let us know. The next railscast/asciicast covers a bit more of the topic, but is probably not relevant for your purposes, as it sounds like you plan on having only say a single subform per child model. I hope that helps. If not please try following along with it, so you get confortable with how it is used in that case, and then ask any more specific questions. Perhaps you want to post attributes for a parent model to a child model. That is tricker, and something we could help you with. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
slindsey3000 wrote:> I have had the worst time getting my forms to accept input for more > than one model. I tried using accepts_nested, and other techniques > and finally got it all working. But it was not fun. I never did get > accepts_nested working!accepts_nested works very easily. If you can tell us what problems you''re having, I''m sure we can help.> > I do need more experience. > > I did hit upon one idea that I just wanted to run by the community. > Let me know what you think. > > If you have one form that will need to send values to several > models.... how about creating a "Form" model with generic attributes. > This "Form" model could for example have fields integer1:integer, > integer2:integer ... etc.. and have fields string1:string, > string2:string..... etc.. > > You would build a "Form" model that could handle any form in your > site. > > Then you just collect the values into this "Form" model.. after they > are in you just assign them to all your other models. No need to go > crazy with all those parameters[][:this][:that].Bad idea. Beside the conceptual wrongness, the resulting params hash will be *harder* to work with (because the names won''t be descriptive), not easier. If you want to do soething like this properly, check out the Presenter pattern.> > It for sure may not be the MOST efficient way to deal with the > database, but it can''t be that bad.It is that bad. Don''t even bother.> > Thoughts? >Learn the framework, don''t fight it and kludge your way around it.> ShawnBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks all! On May 8, 4:03 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> slindsey3000 wrote: > > I have had the worst time getting my forms to accept input for more > > than one model. I tried using accepts_nested, and other techniques > > and finally got it all working. But it was not fun. I never did get > > accepts_nested working! > > accepts_nested works very easily. If you can tell us what problems > you''re having, I''m sure we can help. > > > > > > > I do need more experience. > > > I did hit upon one idea that I just wanted to run by the community. > > Let me know what you think. > > > If you have one form that will need to send values to several > > models.... how about creating a "Form" model with generic attributes. > > This "Form" model could for example have fields integer1:integer, > > integer2:integer ... etc.. and have fields string1:string, > > string2:string..... etc.. > > > You would build a "Form" model that could handle any form in your > > site. > > > Then you just collect the values into this "Form" model.. after they > > are in you just assign them to all your other models. No need to go > > crazy with all those parameters[][:this][:that]. > > Bad idea. Beside the conceptual wrongness, the resulting params hash > will be *harder* to work with (because the names won''t be descriptive), > not easier. If you want to do soething like this properly, check out > the Presenter pattern. > > > > > It for sure may not be the MOST efficient way to deal with the > > database, but it can''t be that bad. > > It is that bad. Don''t even bother. > > > > > Thoughts? > > Learn the framework, don''t fight it and kludge your way around it. > > > Shawn > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.