laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Jan-25 15:37 UTC
Can I use the "scaffold" command to have multiple objects on my page?
I am familiar with how to use scaffold to generate a view where I can create an object. What I would like to do is have a view where I can create multiple of the same object, say five of them. How can I do that? Thanks, - Dave --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Evans
2008-Jan-25 16:59 UTC
Re: Can I use the "scaffold" command to have multiple object
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> I am familiar with how to use scaffold to generate a view where I can > create an object. What I would like to do is have a view where I can > create multiple of the same object, say five of them. How can I do > that?Write your own view. Have one form with separate fields for each of the five objects. So instead of model[field] you have model[1][field] through model[5][field]. Iterate through params[:model] in your create action to create multiple objects. Jeremy -- 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 -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Jan-25 17:15 UTC
Re: Can I use the "scaffold" command to have multiple object
Much obliged for this info. On the controller end, how would I get those objects from the params variable and save them? The object is called line_item and the two attributes are "item_number" and "comments". Thanks again, - Dave On Jan 25, 10:59 am, Jeremy Evans <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: > > I am familiar with how to use scaffold to generate a view where I can > > create an object. What I would like to do is have a view where I can > > create multiple of the same object, say five of them. How can I do > > that? > > Write your own view. Have one form with separate fields for each of the > five objects. So instead of model[field] you have model[1][field] > through model[5][field]. Iterate through params[:model] in your create > action to create multiple objects. > > Jeremy > -- > 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---