Does anyone know how I can repeat fields for a model (that would insert into different records) in a form? E.g. <% form_for @thing, do |f| %> <%= f.submit "DoIt" %> <%= f.text_field :value %> <%= f.text_field :value %> <% end %> So that somehow when the user pressed "DoIt", the first value would go into a record in thing, and the second value would go into another record? Is this possible? TIA, Craig -- 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.
On Mar 10, 10:13 pm, Dudebot <craign...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does anyone know how I can repeat fields for a model (that would > insert into different records) in a form? E.g. > > <% form_for @thing, do |f| %> > <%= f.submit "DoIt" %> > <%= f.text_field :value %> > <%= f.text_field :value %> > <% end %> > > So that somehow when the user pressed "DoIt", the first value would go > into a record in thing, and the second value would go into another > record? Is this possible?As long as you give the fields different names (or nest them in a different scope, eg with fields_for), then yes. You just need to do different things with params[:thing][:value1] and params[:thing] [:value2] in your controller Fred> > TIA, > Craig-- 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.
You probably should have a look into : http://railscasts.com/episodes/73-complex-forms-part-1 Christophe Le 10 mars 2010 à 23:13, Dudebot a écrit :> Does anyone know how I can repeat fields for a model (that would > insert into different records) in a form? E.g. > > <% form_for @thing, do |f| %> > <%= f.submit "DoIt" %> > <%= f.text_field :value %> > <%= f.text_field :value %> > <% end %> > > So that somehow when the user pressed "DoIt", the first value would go > into a record in thing, and the second value would go into another > record? Is this possible? > > TIA, > Craig > > -- > 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. >-- 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.
On Mar 11, 2:10 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Does anyone know how I can repeat fields for a model (that would > > insert into different records) in a form? > As long as you give the fields different names (or nest them in a > different scope, eg with fields_for), then yes. You just need to do > different things with params[:thing][:value1] and params[:thing] > [:value2] in your controller > FredOn Mar 11, 3:33 am, Christophe Decaux <christophe.dec...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You probably should have a look into : > http://railscasts.com/episodes/73-complex-forms-part-1 > ChristopheThanks, Fred and Christophe. I had found the railscast on updating multiple fields, but that wasn''t exactly what I was looking for. I''ll watch the complex forms railscasts, mock up some code and get back to the group if I remain too stupid. Craig -- 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.